Skip to content

Commit 65ce6ba

Browse files
committed
Implementing CSRF case into vuln testing
1 parent 2e00154 commit 65ce6ba

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

data/txt/sha256sums.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ ca86d61d3349ed2d94a6b164d4648cff9701199b5e32378c3f40fca0f517b128 extra/shutils/
160160
df768bcb9838dc6c46dab9b4a877056cb4742bd6cfaaf438c4a3712c5cc0d264 extra/shutils/recloak.sh
161161
1972990a67caf2d0231eacf60e211acf545d9d0beeb3c145a49ba33d5d491b3f extra/shutils/strip.sh
162162
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 extra/vulnserver/__init__.py
163-
0389d8b2248c6c03a215c85adbc0c84227bfe1e3f88ec279a89f59e1225138fe extra/vulnserver/vulnserver.py
163+
d2c300dc997a2cb009376c4ce85f84aa63314ea7f72825c5d6cc10df55918586 extra/vulnserver/vulnserver.py
164164
b8411d1035bb49b073476404e61e1be7f4c61e205057730e2f7880beadcd5f60 lib/controller/action.py
165165
460d3da652b8f55c9eaf0f90be33eddf3355355e5c5b1c98b7fc4d83b1c54fda lib/controller/checks.py
166166
430475857a37fd997e73a47d7485c5dd4aa0985ef32c5a46b5e7bff01749ba66 lib/controller/controller.py
@@ -189,11 +189,11 @@ f5272cda54f7cdd07fb6154d5a1ed1f1141a2a4f39b6a85d3f325fd60ac8dc9a lib/core/enums
189189
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
190190
3574639db4942d16a2dc0a2f04bb7c0913c40c3862b54d34c44075a760e0c194 lib/core/revision.py
191191
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
192-
73270d228b087c53d7f948185bf4962462859280a89811bbe39e1a3b9c0ba481 lib/core/settings.py
192+
64fe31066194ca17a5d829df35947ad68868c8cafd77239debbcc5ec7cfb3c32 lib/core/settings.py
193193
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
194194
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
195195
d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py
196-
bfe2e998fd43498c8682763d77403d9b44600b4e3fb43b44cfa598c7a8a745c2 lib/core/testing.py
196+
03d877d056791cab2de9a9765b9c79f37c1887e509f6b0ceebc9be713853b21c lib/core/testing.py
197197
cf4dca323645d623109a82277a8e8a63eb9abb3fff6c8a57095eb171c1ef91b3 lib/core/threads.py
198198
b9aacb840310173202f79c2ba125b0243003ee6b44c92eca50424f2bdfc83c02 lib/core/unescaper.py
199199
10719f5ca450610ad28242017b2d8a77354ca357ffa26948c5f62d20cac29a8b lib/core/update.py

extra/vulnserver/vulnserver.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
import base64
1313
import json
14+
import random
1415
import re
1516
import sqlite3
17+
import string
1618
import sys
1719
import threading
1820
import traceback
@@ -73,11 +75,15 @@
7375
_lock = None
7476
_server = None
7577
_alive = False
78+
_csrf_token = None
7679

7780
def init(quiet=False):
7881
global _conn
7982
global _cursor
8083
global _lock
84+
global _csrf_token
85+
86+
_csrf_token = "".join(random.sample(string.ascii_letters + string.digits, 20))
8187

8288
_conn = sqlite3.connect(":memory:", isolation_level=None, check_same_thread=False)
8389
_cursor = _conn.cursor()
@@ -142,6 +148,28 @@ def do_REQUEST(self):
142148

143149
self.url, self.params = path, params
144150

151+
if self.url == "/csrf":
152+
if self.params.get("csrf_token") == _csrf_token:
153+
self.url = "/"
154+
else:
155+
self.send_response(OK)
156+
self.send_header("Content-type", "text/html; charset=%s" % UNICODE_ENCODING)
157+
self.end_headers()
158+
159+
form = (
160+
"<html><body>"
161+
"CSRF protection check<br>"
162+
"<form action='/csrf' method='POST'>"
163+
"<input type='hidden' name='csrf_token' value='%s'>"
164+
"id: <input type='text' name='id'>"
165+
"<input type='submit' value='Submit'>"
166+
"</form>"
167+
"</body></html>"
168+
) % _csrf_token
169+
170+
self.wfile.write(form.encode(UNICODE_ENCODING))
171+
return
172+
145173
if self.url == '/':
146174
if not any(_ in self.params for _ in ("id", "query")):
147175
self.send_response(OK)

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from thirdparty import six
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.10.1.15"
22+
VERSION = "1.10.1.16"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/core/testing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def vulnTest():
7575
("-u \"<url>&query=*\" --flush-session --technique=Q --banner", ("Title: SQLite inline queries", "banner: '3.")),
7676
("-d \"<direct>\" --flush-session --dump -T creds --dump-format=SQLITE --binary-fields=password_hash --where \"user_id=5\"", ("3137396164343563366365326362393763663130323965323132303436653831", "dumped to SQLITE database")),
7777
("-d \"<direct>\" --flush-session --banner --schema --sql-query=\"UPDATE users SET name='foobar' WHERE id=5; SELECT * FROM users; SELECT 987654321\"", ("banner: '3.", "INTEGER", "TEXT", "id", "name", "surname", "5,foobar,nameisnull", "'987654321'",)),
78+
("-u <base>csrf --data=\"id=1&csrf_token=1\" --banner --answers=\"update=y\" --flush-session", ("back-end DBMS: SQLite", "banner: '3.")),
7879
("--purge -v 3", ("~ERROR", "~CRITICAL", "deleting the whole directory tree")),
7980
)
8081

0 commit comments

Comments
 (0)