Skip to content

Commit

Permalink
Code Refactoring #1
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-sincek committed Dec 10, 2024
1 parent 8212cee commit fe45630
Show file tree
Hide file tree
Showing 17 changed files with 355 additions and 237 deletions.
3 changes: 0 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
include src/forbidden/*.py
include src/forbidden/*.txt
include src/stresser/*.py
include src/stresser/*.txt
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ python3 -m pip install --upgrade build

python3 -m build

python3 -m pip install dist/forbidden-12.6-py3-none-any.whl
python3 -m pip install dist/forbidden-13.0-py3-none-any.whl
```

## Single URL
Expand Down Expand Up @@ -427,8 +427,8 @@ Inject at the end of the URL path only if it does not end with forward slash.
],
"cookies": [],
"body": null,
"user_agent": "Forbidden/12.6",
"command": "curl --connect-timeout 60 -m 60 -iskL --max-redirs 10 --path-as-is -A 'Forbidden/12.6' -H 'Host: 127.0.0.1' -X 'GET' 'https://example.com:443/admin'",
"user_agent": "Forbidden/13.0",
"command": "curl --connect-timeout 60 -m 60 -iskL --max-redirs 10 --path-as-is -A 'Forbidden/13.0' -H 'Host: 127.0.0.1' -X 'GET' 'https://example.com:443/admin'",
"code": 200,
"length": 255408
},
Expand All @@ -441,8 +441,8 @@ Inject at the end of the URL path only if it does not end with forward slash.
],
"cookies": [],
"body": null,
"user_agent": "Forbidden/12.6",
"command": "curl --connect-timeout 60 -m 60 -iskL --max-redirs 10 --path-as-is -A 'Forbidden/12.6' -H 'Host: 127.0.0.1:443' -X 'GET' 'https://example.com:443/admin'",
"user_agent": "Forbidden/13.0",
"command": "curl --connect-timeout 60 -m 60 -iskL --max-redirs 10 --path-as-is -A 'Forbidden/13.0' -H 'Host: 127.0.0.1:443' -X 'GET' 'https://example.com:443/admin'",
"code": 200,
"length": 255408
}
Expand All @@ -452,7 +452,7 @@ Inject at the end of the URL path only if it does not end with forward slash.
## Usage

```fundamental
Forbidden v12.6 ( github.com/ivan-sincek/forbidden )
Forbidden v13.0 ( github.com/ivan-sincek/forbidden )
Usage: forbidden -u url -t tests [-f force] [-v values ] [-p path ] [-o out ]
Example: forbidden -u https://example.com/admin -t all [-f POST ] [-v values.txt] [-p /home] [-o results.json]
Expand Down Expand Up @@ -527,7 +527,7 @@ SLEEP
-s, --sleep = 500 | etc.
USER AGENT
User agent to use
Default: Forbidden/12.6
Default: Forbidden/13.0
-a, --user-agent = curl/3.30.1 | random[-all] | etc.
PROXY
Web proxy to use
Expand All @@ -553,7 +553,7 @@ DEBUG
```

```fundamental
Stresser v12.6 ( github.com/ivan-sincek/forbidden )
Stresser v13.0 ( github.com/ivan-sincek/forbidden )
Usage: stresser -u url -dir directory -r repeat -th threads [-f force] [-o out ]
Example: stresser -u https://example.com/secret -dir results -r 1000 -th 200 [-f GET ] [-o results.json]
Expand Down Expand Up @@ -603,7 +603,7 @@ THREADS
-th, --threads = 20 | etc.
USER AGENT
User agent to use
Default: Stresser/12.6
Default: Stresser/13.0
-a, --user-agent = curl/3.30.1 | random[-all] | etc.
PROXY
Web proxy to use
Expand Down
24 changes: 15 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
[build-system]
requires = ["setuptools>=61.0"]
requires = ["setuptools>=75.3.0"]
build-backend = "setuptools.build_meta"

[project]
name = "forbidden"
version = "12.6"
version = "13.0"
authors = [{ name = "Ivan Sincek" }]
description = "Bypass 4xx HTTP response status codes and more. Based on PycURL and Python Requests."
readme = "README.md"
requires-python = ">=3.6"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"
]
dependencies = ["alive-progress>=3.1.5", "colorama>=0.4.6", "pycurl>=7.45.2", "pyjwt>=2.7.0", "regex>=2023.8.8", "requests>=2.31.0", "tabulate>=0.9.0", "termcolor>=2.4.0"]
dependencies = [
"alive-progress>=3.1.5",
"colorama>=0.4.6",
"pycurl>=7.45.2",
"pyjwt>=2.7.0",
"regex>=2023.8.8",
"requests>=2.31.0",
"tabulate>=0.9.0",
"termcolor>=2.4.0"
]

[project.urls]
"Homepage" = "https://github.com/ivan-sincek/forbidden"

[project.scripts]
forbidden = "forbidden.forbidden:main"
stresser = "stresser.stresser:main"
forbidden = "forbidden.main:main"
stresser = "stresser.main:main"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
"*" = ["user_agents.txt"]
Empty file removed src/forbidden/__init__.py
Empty file.
14 changes: 2 additions & 12 deletions src/forbidden/forbidden.py → src/forbidden/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def write_file(data, out):

# ----------------------------------------

default_user_agent = "Forbidden/12.6"
default_user_agent = "Forbidden/13.0"

def get_all_user_agents():
tmp = []
Expand Down Expand Up @@ -1695,7 +1695,7 @@ def show_results(self):
class MyArgParser(argparse.ArgumentParser):

def print_help(self):
print("Forbidden v12.6 ( github.com/ivan-sincek/forbidden )")
print("Forbidden v13.0 ( github.com/ivan-sincek/forbidden )")
print("")
print("Usage: forbidden -u url -t tests [-f force] [-v values ] [-p path ] [-o out ]")
print("Example: forbidden -u https://example.com/admin -t all [-f POST ] [-v values.txt] [-p /home] [-o results.json]")
Expand Down Expand Up @@ -2041,16 +2041,6 @@ def __parse_dump(self):
def main():
validate = Validate()
if validate.run():
print("###########################################################################")
print("# #")
print("# Forbidden v12.6 #")
print("# by Ivan Sincek #")
print("# #")
print("# Bypass 4xx HTTP response status codes and more. #")
print("# GitHub repository at github.com/ivan-sincek/forbidden. #")
print("# Feel free to donate ETH at 0xbc00e800f29524AD8b0968CEBEAD4cD5C5c1f105. #")
print("# #")
print("###########################################################################")
out = validate.get_arg("out")
dump = validate.get_arg("dump")
forbidden = Forbidden(
Expand Down
96 changes: 0 additions & 96 deletions src/forbidden/user_agents.txt

This file was deleted.

19 changes: 19 additions & 0 deletions src/forbidden/utils/array.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3

def unique(array: list):
"""
Remove duplicates from a list.
"""
seen = set()
return [x for x in array if not (x in seen or seen.add(x))]

def remove_empty_strings(array: list[str]) -> list[str]:
"""
Strip whitespace from each string in a list, and remove empty strings.
"""
tmp = []
for entry in array:
entry = entry.strip()
if entry:
tmp.append(entry)
return tmp
19 changes: 19 additions & 0 deletions src/forbidden/utils/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3

APP_VERSION = "v13.0"

USER_AGENT = "Forbidden/13.0"

def banner():
"""
Display the banner.
"""
print("#########################################################################")
print("# #")
print("# Forbidden v13.0 #")
print("# by Ivan Sincek #")
print("# #")
print("# Bypass 4xx HTTP response status codes and more. #")
print("# GitHub repository at github.com/ivan-sincek/forbidden. #")
print("# #")
print("#########################################################################")
7 changes: 7 additions & 0 deletions src/forbidden/utils/general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python3

def print_error(message: str):
"""
Print an error message.
"""
print(f"ERROR: {message}")
40 changes: 40 additions & 0 deletions src/forbidden/utils/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import enum

class Type(enum.Enum):
"""
Enum containing supported tests.
"""
BASE = "base"
METHODS = "methods"
METHOD_OVERRIDES = "method-overrides"
SCHEME_OVERRIDES = "scheme-overrides"
PORT_OVERRIDES = "port-overrides"
HEADERS = "headers"
VALUES = "values"
PATHS = "paths"
PATHS_RAM = "paths-ram"
ENCODINGS = "encodings"
AUTHS = "auths"
REDIRECTS = "redirects"
PARSERS = "parsers"

@classmethod
def all(cls):
"""
Get all tests.
"""
return [
cls.BASE,
cls.METHODS,
cls.METHOD_OVERRIDES,
cls.SCHEME_OVERRIDES,
cls.PORT_OVERRIDES,
cls.HEADERS,
cls.VALUES,
cls.PATHS,
cls.PATHS_RAM,
cls.ENCODINGS,
cls.AUTHS,
cls.REDIRECTS,
cls.PARSERS
]
File renamed without changes.
Loading

0 comments on commit fe45630

Please sign in to comment.