
نصائح حول كيفية كتابة سكربتات الاستغلال (بشكل أسرع!)
يحتوي هذا المستودع على قائمة من المقتطفات والنصائح المفيدة المتعلقة بكتابة سكربتات الاستغلال في مختبرات وامتحان شهادة OSWE.
بعض الأمثلة هنا قد تخالف بعض ممارسات البرمجة السليمة، لكن هدفنا النهائي هو كتابة سكربت الاستغلال بسرعة وبشكل صحيح.
يُعد قسم مقتطفات برمجية مكانًا رائعًا للبدء إذا لم تكن لديك خبرة في استخدام مكتبة
requestsأو كنت جديدًا على Python. وإلا، فلا تتردد في الانتقال إلى قسم كود قابل لإعادة الاستخدام أو قسم نصائح.
requests
params)data)json)files)headers)cookies)3XX (باستخدام وسيط allow_redirects)verify)proxies)SessionassertSession عام بحيث لا يحتاج إلى تمريره صراحةً لكل استدعاء دالةBASE_URL عامة وإنشاء الروابط المطلوبة منهاproxies، عيّن متغير البيئة HTTP_PROXY / HTTPS_PROXY عند التشغيل""" لإنشاء سلسلة الحمولة إذا كانت تحتوي على كلٍّ من علامات الاقتباس المفردة (') والمزدوجة (")f"") أو str.format إذا كانت الحمولة تحتوي على عدد كبير جدًا من الأقواس المتعرجة ({})import requests
def main():
print("Hello World!")
if __name__ == __main__:
main()
# For sending HTTP requests
import requests
# For Base64 encoding/decoding
from base64 import b64encode, b64decode, urlsafe_b64encode, urlsafe_b64decode
# For getting current time or for calculating time delays
from time import time
# For regular expressions
import re
# For running shell commands
import subprocess
# For multithreading
from concurrent.futures import ThreadPoolExecutor
# For running a HTTP server in the background
import threading
from http.server import HTTPServer, BaseHTTPRequestHandler
# For parsing HTTP cookies
from http import cookies
# For getting command-line arguments
import sys
requestsresp_obj = requests.get("https://github.com")
# GET method
requests.get("https://github.com")
# POST method
requests.post("https://github.com")
# PUT method
requests.put("https://github.com")
# PATCH method
requests.patch("https://github.com")
# DELETE method
requests.delete("https://github.com")
resp_obj = requests.get("https://github.com")
# HTTP status code (e.g 404, 500, 301)
resp_obj.status_code
# HTTP response headers (e.g Location, Content-Disposition)
resp_obj.headers["Location"]
# Body as bytes
resp_obj.content
# Body as a string
resp_obj.text
# Body as a dictionary (if body is a JSON)
resp_obj.json()
params)params = {
"foo": "bar"
}
requests.get("https://github.com", params=params)
data)data = {
"foo": "bar"
}
requests.post("https://github.com", data=data)
json)data = {
"foo": "bar"
}
requests.post("https://github.com", json=data)