Defang API
Defang API runs a local server or Docker that can assist in defanging URLs to make them safe to post in various apps or tp log in case logs.
Capabilities:
- Defang URL
- Refang URL
- Base64 Decode
- Base64 Encode
The defang functionality is ran using a a modified version of the defang package from Johan Nestaas. I currently a pull request in to incorporate the changes I have made to it to better support more protocols and defanging options.
Original: https://bitbucket.org/johannestaas/defang/src/master/
Mine: https://bitbucket.org/zpriddy/defang/src/master/
Pull Request: https://bitbucket.org/johannestaas/defang/pull-requests/4/add-better-support-for-defanging/diff
Installing and Running
Using PIP (Easy)
Install
Run : pip install defang-api
Running
Run: defang-server
By default this will run on localhost on port 5000 but that can be changed at runtime:
defang-server --port=8080 --host-0.0.0.0
Using Docker (Advanced)
Install
Requirements:
- Docker Installed
brew install docker
- Docker Compose installed
brew install docker-compose
Clone the repo: git clone https://github.com/zpriddy/defang_api.git
Running
Run: cd defang_api
Run: docker-compose up
Using Defang API
When you launch the server by default it will run on localhost:5000.
There is full Swagger documentation if you point your browser at
http://localhost:5000. This will give you full details on all of the available options for each
endpoint of the API as well as the ability to test each of the endpoints.
By default the API will return its results in JSON but if accept header is set to text/plain
then it will return the results in plain text.
Examples
If you run:
curl -X GET "http://localhost:5000/api/defang?url=http%3A%2F%2Fexample.com" -H "accept: text/plain"
You will get back
hXXp://example[.]com
curl -X GET "http://localhost:5000/api/defang?url=http%3A%2F%2Fexample.com" -H "accept: application/json"
Will give you back JSON:
{
"error": [],
"output": "hXXp://example[.]com"
}
If you have a list of URLS:
curl -X POST "http://localhost:5000/api/defang" -H "accept: application/json" -H "Content-Type: "\
"application/json" -d "{ \"colons\": false, \"dots\": false, \"url\": [ \"https://example.com\", \"https://foo.bar\" ]}"
Will give you:
{
"error": [],
"output": [
"hXXps://example[.]com",
"hXXps://foo[.]bar"
]
}
But if you set the accept to text/plain you will get:
hXXps://example[.]com,hXXps://foo[.]bar
Notes
The simple GET method endpoints are limited on the scope of options that there are in passing
data in. For this reason I recommend using the POST method endpoints
Metadata
Release files for defang-api 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| defang_api-0.0.1.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| defang_api-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.6 kB
Release files / defang_api-0.0.1.tar.gz
| Download URL | defang_api-0.0.1.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23c5eebb1e96d6de2b8328fa4dda74e430eddb2c2cc69608b98f81d09cdf0612
|
|
BLAKE2b-256 checksum How to use checksums |
2a5c85438d8f43ee5cce9d2f3e0e0f9ecbda047ec0f767b17fce280a2f1a0a7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|
Release files / defang_api-0.0.1-py3-none-any.whl
| Download URL | defang_api-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efc137f401e70b3854a0fc0543fc8721e50fa832bad431b386dc7501e7a72ffc
|
|
BLAKE2b-256 checksum How to use checksums |
833f4baf60d87447c0b57a6eacd19878aa0e43cdd74d407f695ade8f9ec14982
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|