• SWPU NSS新生赛(校外通道)


    目录

    numgame

    Ez_upload

    js_sign 

    funny_web


    numgame

     打开界面以后,发现禁用了ctrl+u和查看源码, 

    然后抓包或f12,看见提示了超链接/js/1.js,访问试一下

    base64解码,NsScTf.php ,访问

    1. error_reporting(0);
    2. //hint: 与get相似的另一种请求协议是什么呢
    3. include("flag.php");
    4. class nss{
    5. static function ctf(){
    6. include("./hint2.php");
    7. }
    8. }
    9. if(isset($_GET['p'])){
    10. if (preg_match("/n|c/m",$_GET['p'], $matches))
    11. die("no");
    12. call_user_func($_GET['p']);
    13. }else{
    14. highlight_file(__FILE__);
    15. }

    我们的目的,就是通过get传参p然后,借助 call_user_func调用nss中的ctf静态方法

    if (preg_match("/n|c/m",$_GET['p'], $matches))

    就是禁用了n和c,然后/m以多文本形式,

    call_user_func($_GET['p']);调用p传入的函数

    这里普及一个知识点

     可以通过NSS::CTF调用类中的CTF的静态方法,这里的类名和方法名不区分大小写

    所以我们就可以大写绕过

    看见提示然后查看源码,出flag 

    Ez_upload

    一开始只要用,.htaccess     AddType application/x-httpd-php .jpg

    然后更改 content-type的类型为:jpeg/image

    然后上传一个.jpg文件木马就可以,禁了

     用这个代替,可是链接上了建蚁

    flag为空

    js_sign 

    打开源码,访问超链接

    1. document.getElementsByTagName("button")[0].addEventListener("click", ()=>{
    2. flag="33 43 43 13 44 21 54 34 45 21 24 33 14 21 31 11 22 12 54 44 11 35 13 34 14 15"
    3. if (btoa(flag.value) == 'dGFwY29kZQ==') {
    4. alert("you got hint!!!");
    5. } else {
    6. alert("fuck off !!");
    7. }
    8. })

    发现如下源码,看见base64解密tapcode百度是一种编码的格式

     得到flagTap Code | Boxentriq

    funny_web

    1. session_start();
    2. highlight_file(__FILE__);
    3. if(isset($_GET['num'])){
    4. if(strlen($_GET['num'])<=3&&$_GET['num']>999999999){
    5. echo ":D";
    6. $_SESSION['L1'] = 1;
    7. echo "=================";
    8. }else{
    9. echo ":C";
    10. }//让num长度小于3,并且大于999999999,想到了浮点型9e9
    11. }
    12. if(isset($_GET['str'])){
    13. $str = preg_replace('/NSSCTF/',"",$_GET['str']);
    14. if($str === "NSSCTF"){//经过过滤仍然等于NSSCTF
    15. echo "wow";
    16. $_SESSION['L2'] = 1;//这里想到了 NSSNSSCTFCTF 这样双写绕过
    17. }else{
    18. echo $str;
    19. }
    20. }
    21. if(isset($_POST['md5_1'])&&isset($_POST['md5_2'])){
    22. if($_POST['md5_1']!==$_POST['md5_2']&&md5($_POST['md5_1'])==md5($_POST['md5_2'])){
    23. echo "Nice!";
    24. if(isset($_POST['md5_1'])&&isset($_POST['md5_2'])){
    25. if(is_string($_POST['md5_1'])&&is_string($_POST['md5_2'])){
    26. echo "yoxi!";
    27. $_SESSION['L3'] = 1;//md5弱类型,并且双方为字符串
    28. }else{
    29. echo "X(";
    30. }
    31. }
    32. }else{
    33. echo "G";
    34. echo $_POST['md5_1']."\n".$_POST['md5_2'];
    35. }
    36. }
    37. ?>

    file_master

     比赛结束后,放出了源码,才恍然大悟,其实不难,就是自己要重复实验操作

    1. session_start();
    2. if(isset($_GET['filename'])){
    3. echo file_get_contents($_GET['filename']);
    4. }
    5. else if(isset($_FILES['file']['name'])){
    6. $whtie_list = array("image/jpeg");
    7. $filetype = $_FILES["file"]["type"];
    8. if(in_array($filetype,$whtie_list)){
    9. $img_info = @getimagesize($_FILES["file"]["tmp_name"]);
    10. if($img_info){
    11. if($img_info[0]<=20 && $img_info[1]<=20){
    12. if(!is_dir("upload/".session_id())){
    13. mkdir("upload/".session_id());
    14. }
    15. $save_path = "upload/".session_id()."/".$_FILES["file"]["name"];
    16. move_uploaded_file($_FILES["file"]["tmp_name"],$save_path);
    17. $content = file_get_contents($save_path);
    18. if(preg_match("/php/i",$content)){
    19. sleep(5);
    20. @unlink($save_path);
    21. die("hacker!!!");
    22. }else{
    23. echo "upload success!! upload/your_sessionid/your_filename";
    24. }
    25. }else{
    26. die("image hight and width must less than 20");
    27. }
    28. }else{
    29. die("invalid file head");
    30. }
    31. }else{
    32. die("invalid file type!image/jpeg only!!");
    33. }
    34. }else{
    35. echo 'base64_encode(file_get_contents("welcome.jpg")).'">';
    36. }
    37. ?>

     提醒我们无效的头文件,

     然后GIF89a,提示我们图像宽高小于20

     去掉文件头上传成功,然后写一句话木马

     有延迟然后报错,估计是php被过滤掉了

    php短标签上传成功,上传路径由upload/sessionid/文件名构成 

    获得flag 

    Power!

    1. class FileViewer{
    2. public $black_list = "flag";
    3. public $local = "http://127.0.0.1/";
    4. public $path;
    5. public function __call($f,$a){
    6. $this->loadfile();
    7. }
    8. public function loadfile(){
    9. if(!is_array($this->path)){
    10. if(preg_match("/".$this->black_list."/i",$this->path)){
    11. $file = $this->curl($this->local."cheems.jpg");
    12. }else{
    13. $file = $this->curl($this->local.$this->path);
    14. }
    15. }else{
    16. $file = $this->curl($this->local."cheems.jpg");
    17. }
    18. echo 'base64_encode($file).'"/>';
    19. }
    20. public function curl($path){
    21. $url = $path;
    22. $curl = curl_init();
    23. curl_setopt($curl, CURLOPT_URL, $url);
    24. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    25. curl_setopt($curl, CURLOPT_HEADER, 0);
    26. $response = curl_exec($curl);
    27. curl_close($curl);
    28. return $response;
    29. }
    30. public function __wakeup(){
    31. $this->local = "http://127.0.0.1/";
    32. }
    33. }
    34. class Backdoor{
    35. public $a;
    36. public $b;
    37. public $superhacker = "hacker.jpg";
    38. public function goodman($i,$j){
    39. $i->$j = $this->superhacker;
    40. }
    41. public function __destruct(){
    42. $this->goodman($this->a,$this->b);
    43. $this->a->c();
    44. }
    45. }
    46. if(isset($_GET['source'])){
    47. highlight_file(__FILE__);
    48. }else{
    49. if(isset($_GET['image_path'])){
    50. $path = $_GET['image_path']; //flag in /flag.php
    51. if(is_string($path)&&!preg_match("/http:|gopher:|glob:|php:/i",$path)){
    52. echo 'base64_encode(file_get_contents($path)).'"/>';
    53. }else{
    54. echo '

      Seriously??

      base64_encode
      (file_get_contents("cheems.jpg")).'"/>';
    55. }
    56. }else if(isset($_GET['path_info'])){
    57. $path_info = $_GET['path_info'];
    58. $FV = unserialize(base64_decode($path_info));
    59. $FV->loadfile();
    60. }else{
    61. $path = "vergil.jpg";
    62. echo '

      POWER!!

    63. base64_encode(file_get_contents($path)).'"/>';
    64. }
    65. }
    66. ?>

    呃呃呃还没弄懂,先欠着

  • 相关阅读:
    iOS 将字符串分割成单个字符| 字符串转成数组
    学习Python低手之路【三】python基础之函数
    【Node.JS 】服务器相关的概念
    linux apt-get安装Jenkins
    Zenmap安装及安装时遇到的问题解决办法(Windows)
    8 - 函数
    python socket 传输opencv读取的图像
    侯捷 C++ STL标准库和泛型编程 —— 9 STL周围
    30出头成为复旦博导,陈思明:敲代码和写诗,我两样都要
    vue导出word文档
  • 原文地址:https://blog.csdn.net/qq_62046696/article/details/127540354