Skip to content

Commit

Permalink
Merge pull request #3 from malvads/add_multi_param
Browse files Browse the repository at this point in the history
Add multi param
  • Loading branch information
malvads authored May 19, 2024
2 parents a4db9e0 + 19d1045 commit 19051ae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlmc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.1.0
27 changes: 27 additions & 0 deletions sqlmc/lib/injector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Injector:
@staticmethod
def inject(url):
query_start = url.find('?')
if query_start == -1:
return url

base_url = url[:query_start]
query_string = url[query_start+1:]
params = query_string.split('&')

modified_params = []
for param in params:
key_value = param.split('=')
if len(key_value) == 2:
key = key_value[0]
value = key_value[1]
# Add single quotes around the value
modified_value = f"{value}'"
modified_params.append(f"{key}={modified_value}")
else:
modified_params.append(param)

modified_query_string = '&'.join(modified_params)
modified_url = f"{base_url}?{modified_query_string}"

return modified_url
4 changes: 4 additions & 0 deletions sqlmc/lib/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
from datetime import datetime
from sqlmc.lib.error import Checker
from sqlmc.lib.injector import Injector
from bs4 import BeautifulSoup

logging.basicConfig(level=logging.INFO)
Expand All @@ -29,6 +30,7 @@ async def get_server(self):
return response.headers.get('Server', 'Unknown')

async def test_for_sql_injection(self, url):
url = Injector.inject(url)
async with aiohttp.ClientSession() as session:
async with session.get(url + "'") as response:
return self.check(await response.text())
Expand Down Expand Up @@ -60,6 +62,8 @@ async def scan(self, url, depth):
await asyncio.gather(*tasks)
except aiohttp.ClientError:
pass
except UnicodeDecodeError:
pass

async def scan_single_link(self, href, depth):
vulnerable, db = await self.test_for_sql_injection(href)
Expand Down

0 comments on commit 19051ae

Please sign in to comment.