Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function 'preprocess(req)' in preprocess script 'preprocess.py' appears to be invalid #5567

Closed
freetom opened this issue Nov 10, 2023 · 2 comments

Comments

@freetom
Copy link

freetom commented Nov 10, 2023

Describe the bug
Can't use custom preprocess scripts because of errors from sqlmap which I don't understand.
With certain scripts sqlmap runs smoothly, but as soon as I put for example getattribute(), calls to requests methods, or even subprocess, I get the below error.

Why is that?

To Reproduce

  1. Place preprocess.py in current folder with:
#!/usr/bin/env python
import requests

def preprocess(req):
    url = 'http://localhost'
    r = requests.get(url)
  1. Run sqlmap on whatever with --preprocess=./preprocess.py

  2. Get this error:
    [14:13:21] [CRITICAL] function 'preprocess(req)' in preprocess script 'preprocess.py' appears to be invalid (Note: find template script at '/tmp/sqlmaptiax05q726027/sqlmappreprocess-0n3_58t2.py')

Expected behavior
Run smoothly

Running environment:

  • sqlmap version [1.7.10.5#dev]
  • Installation method [apt]
  • Operating system: [Debian 12]
  • Python version [3.11.2]

Additional context
I could not find anything on the above error and can't figure out why or what is going wrong and how to fix it.

@IRedScarface
Copy link
Contributor

If certain functionalities are restricted, consider modifying your approach to achieve the desired result without using those specific functions. For example, if requests are not allowed, you might need to find an alternative method to achieve the same goal.

#!/usr/bin/env python

def preprocess(req):
# Your custom preprocessing logic here
req['url'] = 'http://localhost'
return req

stamparm added a commit that referenced this issue Nov 12, 2023
@stamparm
Copy link
Member

@freetom you've put a pure junk into there, where sqlmap had problems in a test run. With the latest revision you'll have a more verbose error message:

[20:26:05] [INFO] loading preprocess module 'preprocess'
[20:26:05] [CRITICAL] function 'preprocess(req)' in preprocess script './preprocess.py' had issues in a test run ('HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f316b908750>: Failed to establish a new connection: [Errno 111] Connection refused'))'). You can find a template script at '/tmp/sqlmapcrjz76tp33899/sqlmappreprocess-1rzlk8b8.py'

Wendlg0 pushed a commit to Wendlg0/sqlmap that referenced this issue May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants