Skip to content

Instantly share code, notes, and snippets.

View 0xdade's full-sized avatar

dade 0xdade

View GitHub Profile
@0xdade
0xdade / proxy_protocol.md
Created February 13, 2020 04:06
Reverse Proxying with PROXY PROTOCOL in Nginx

Summary

Reverse proxy SSL connections and retain the originating IP address without terminating SSL at the mid-point. This makes use of the PROXY protocol.

Testing Configuration

This example setup uses nginx version: nginx/1.14.0 (Ubuntu) as it ships out of the box with ubuntu 18.04.4 LTS. It was last tested on 2020-02-12.

Example Configuration to log originating IP

DNS example.com points to 192.168.10.10 192.168.10.10 has nginx installed with this in /etc/nginx/nginx.conf OUTSIDE OF the http block

@0xdade
0xdade / selfdestruct.py
Created January 23, 2020 04:26
Simple code snippet for a python file to delete itself, whether it's a standalone .py file or compiled into an executable using pyinstaller
#!/usr/bin/env python3
'''
Determine if this python is part of an executable or a standalone script and then delete the file accordingly.
If the script has been bundled into an executable using pyinstaller (such as pyinstaller --onefile <fname>.py) then the realpath of __file__ will be incorrect, thus the use of sys.executable.
Example of just relying on __file__:
$ pyinstaller --onefile test.py
[...]
$ ls dist/
@0xdade
0xdade / tags.py
Created April 9, 2022 23:01
Some really awful ways to build html elements in python. attributes with - in them not supported. Self-closing tags not supported. Comments not supported. Doctype strings not supported. attribute validation on tags not supported.
# First approach, just make a function manually for every tag
# Then feed them all back to the same core html_element function for rendering
import inspect
import sys
def html_element(*args, **kwargs):
tag = inspect.stack()[1][3]
attrs = [f"{kwarg}=\"{kwargs.get(kwarg)}\"" for kwarg in kwargs]
children = "\n".join([f"{child}" for child in args])
return f'<{tag}{" " if attrs else ""}{" ".join(attrs)}>{children}</{tag}>'
@0xdade
0xdade / secure_file_submit_share.txt
Last active April 30, 2021 07:07
Some design thoughts on building an open source solution for solving the "simple secure file submission" and "simple secure file share" problems
User Experience:
Workflow:
(Optional) Click pre-authenticated upload url, if provided
(Optional) Sign in, if required
Drag and drop a file
interface shows the file name (and maybe some additional metadata, not sure if we get any metadata at this point though)
Set of checkboxes for the following (if they are not enforced to a specific value by the server operator):
Save Encryption Key
Burn After Reading
Expiration Duration
@0xdade
0xdade / apache-modrewrite-cloud.conf
Last active February 23, 2021 18:19
Rickroll clouds with apache mod_rewrite
This file has been truncated, but you can view the full file.
# Built by Sephiroth on 2020-06-24 03:05:40.431464 (UTC)
# (aws) syncToken: 1592887752
# (aws) createDate: 2020-06-23-04-49-12
# (azure) changeNumber: 95
# (azure) cloud: Public
# (gcp) _cloud-netblocks count: 8
# (oci) last_updated_timestamp: 2020-06-19T14:53:54.841671
# (asn) ASN Data collected from api.hackertarget.com
@0xdade
0xdade / auto-limiter.yml
Last active September 29, 2020 05:01
Github action to automatically limit the repo to collaborators every day. REPO_MANAGER is a personal access token in the repository secrets. Gross, but github doesn't give us individual repo admin tokens because it's 2020 and principle of yoloscope
name: Automatically limit
on:
schedule:
- cron: "0 0 * * *"
jobs:
limiter:
runs-on: ubuntu-latest
steps:
- name: Remove existing limit
run: |
# A quick nginx config that does some shameless transparent proxying.
# The sub_filter module is available on my ubuntu install out of the box, but may not always be available
# This demonstration of sub_filter is also extremely minimal. All requests that begin with `/` will load relatively anyways, this attempts to replace any fully qualified requests
server {
listen 80;
listen [::]:80;
server_name exploit.party;
return 301 https://$server_name$request_uri;
}
@0xdade
0xdade / wildcard_nginx_config.md
Last active June 28, 2020 03:07
Distribute the denial of secrets

Distributing the denial of secrets

Twitter made ddosecrets.com a forbidden place. I don't like being forbidden from going places or sharing links to said places.

It's dangerous to go alone, take these:

@0xdade
0xdade / nginx-cloud-block.conf
Last active June 24, 2020 04:35
Block clouds in nginx with ngx_http_geo_module
This file has been truncated, but you can view the full file.
# Built by Sephiroth on 2020-06-24 03:05:20.327355 (UTC)
# (aws) syncToken: 1592887752
# (aws) createDate: 2020-06-23-04-49-12
# (azure) changeNumber: 95
# (azure) cloud: Public
# (gcp) _cloud-netblocks count: 8
# (oci) last_updated_timestamp: 2020-06-19T14:53:54.841671
# (asn) ASN Data collected from api.hackertarget.com
geo $block_ip {
@0xdade
0xdade / iptables-cloud-block
Last active June 24, 2020 03:07
DROP clouds using iptables
This file has been truncated, but you can view the full file.
# Built by Sephiroth on 2020-06-24 03:04:16.607901 (UTC)
# (aws) syncToken: 1592887752
# (aws) createDate: 2020-06-23-04-49-12
# (azure) changeNumber: 95
# (azure) cloud: Public
# (gcp) _cloud-netblocks count: 8
# (oci) last_updated_timestamp: 2020-06-19T14:53:54.841671
# (asn) ASN Data collected from api.hackertarget.com
*filter