
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
A library written for finding differences between HTTP responses.
HTTPDiff is a library built for finding differences between responses.
A lot of web pentesting tools suck, using regexes or hardcoded values to determine whether something is different. These methods will produce false-negatives no matter how much you tweak those values. HTTPDiff attempts to use a more dynamic way of differentiation responses, attempting to reduce the false-negatives produced during a scan.
By sending multiple requests with a known outcome, it is possible to calibrate a baseline of how the application normally behaves. HTTPDiff can then be used to find deviations from the default behavior. HTTPDiff will analyze every section of the response; the status code, reason, headers, body, response time, and even errors.
Want to create a SQL injection scanner? Send a bunch of payloads with random strings for calibration, then send pairs of payloads (e.g. ' or '1'='1 and ' or '1'='2) and check for differences!
If you want to brute-force endpoints and directories on a web application, you can start by sending a series of requests to known invalid endpoints. The baseline can now be used to determine if any other endpoints behave in a similar way, or are somehow different. Go to Diffuzz for a good example on how to utilize this library.
python3 -m pip install httpdiff
Here comes some details of how the library is built, feel free to skip this section if you're not interested:
,.; and whitespaces
. A list of these bytes are stored as the original lines.git diff
) is used to generate opcodes describing how to transform the original lines to the new lines.Go visit Diffuzz to see an awesome fuzzer utilizing HTTPDiff.
Here's a small example script showing how HTTPDiff can be used:
from httpdiff import Response, Baseline
import string
import random
import requests
def calibrate_baseline(baseline):
for _ in range(10):
value = "".join(random.choice(string.ascii_letters) for _ in range(random.randint(3,15)))
resp = requests.get(f"https://someurl/endpoint?parameter={value}")
httpdiff_resp = Response(resp)
baseline.add_response(httpdiff_resp,payload=value) # Adding value as a parameter for finding reflections
# Often smart to repeat a single payload twice including a potentially cached response in the baseline
resp = requests.get(f"https://someurl/endpoint?parameter={value}")
httpdiff_resp = Response(resp)
baseline.add_response(httpdiff_resp,payload=value)
def scan(baseline):
payload1 = "' or '1'='1"
resp = requests.get(f"https://someurl/endpoint?parameter={payload1}")
httpdiff_resp1 = Response(resp)
# payload2 in this example is supposed to contain a similar payload, but a different result if vulnerable. Kind of an opposite payload.
payload2 = "' or '1'='2"
resp = requests.get(f"https://someurl/endpoint?parameter={payload2}")
httpdiff_resp2 = Response(resp)
diffs = list(baseline.is_diff(httpdiff_resp1))
diffs2 = list(baseline.is_diff(httpdiff_resp2))
if diffs != diffs2:
print("Vulnerable to SQL Injection!")
else:
print("Not vulnerable to SQL injection!")
def main():
baseline = Baseline()
calibrate_baseline(baseline)
scan(baseline)
if __name__ == "__main__":
main()
Some tips for successfully creating your own scanner of some sort:
FAQs
HTTPDiff - Finding differences between HTTP responses
We found that httpdiff demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.