Skip to content

Instantly share code, notes, and snippets.

View 19h's full-sized avatar
✔️
This account is verified.

Kenan Sulayman 19h

✔️
This account is verified.
View GitHub Profile
@19h
19h / code.ts
Created March 28, 2024 01:47
Github Copilot goes bonkers
const x = (full_name): string[] => {
citizen_database.filter(person =>
/ibrahim|ali|mohamm(?:a|e)d/.test(person.name),
).forEach(person =>
(person.tags.push('illegal immigrant'), person)
);
const x = () => {
citizen_database.filter(person =>
/ibrahim|ali|mohamm(?:a|e)d/.test(person.name),
@19h
19h / ld.c
Created February 17, 2014 13:37
Decrypting Plesk Panel PHP files (stolen from @silentsignal)

Hooking memcpy of swengine

  1. /tmp root@apx# nano ld.c
  2. /tmp root@apx# gcc -fPIC -c ld.c -o ld.o
  3. /tmp root@apx# gcc -shared -o ld.so ld.o
  4. /tmp root@apx# LD_PRELOAD=/tmp/ld.so /usr/bin/sw-engine /usr/local/psa/admin/htdocs/login_up.php3

Cheers

@19h
19h / embedder.py
Created November 3, 2023 23:18
This Python code efficiently extracts sentence embeddings from a CSV of news articles using a pretrained BERT model. It batches titles, generates embeddings, serializes them, and writes the embeddings and metadata to a new CSV file.
import csv
import json
import torch
from tqdm import tqdm
from transformers import AutoModel, BertTokenizerFast
import ctypes as ct
csv.field_size_limit(int(ct.c_ulong(-1).value // 2))
model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-en', trust_remote_code=True)
@19h
19h / embedder.py
Created November 3, 2023 23:16
This Python code efficiently extracts sentence embeddings from a large CSV dataset of news articles using a pretrained BERT model for natural language processing. It first loads the BERT model and tokenizer, then reads the input CSV row by row, extracting the title and article text. It batches the titles, feeds them to the BERT model to generate…
import csv
import json
import torch
from tqdm import tqdm
from transformers import AutoModel, BertTokenizerFast
import ctypes as ct
csv.field_size_limit(int(ct.c_ulong(-1).value // 2))
model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-en', trust_remote_code=True)
@19h
19h / PE.js
Last active July 19, 2023 13:34
A Probabilistic Encryption Algorithm (V8/ECMA)
var encrypt = function (i, d) {
if (null == d || 0 >= d.length) return null;
for (var a = "", b = 0; b < d.length; b++) a += d.charCodeAt(b).toString();
var b = Math.floor(a.length / 5),
g = parseInt(a.charAt(b) + a.charAt(2 * b) + a.charAt(3 * b) + a.charAt(4 * b) + a.charAt(5 * b), 10),
j = Math.ceil(d.length / 2),
h = Math.pow(2, 31) - 1;
if (2 > g) return null;
for (var c = Math.round(1E9 * Math.random()) % 1E8, a = a + c; 10 < a.length;) a = (parseInt(a.substring(0, 10), 10) + parseInt(a.substring(10, a.length), 10)).toString();
for (a = (g * a + j) % h, e = "", f = "", b = 0; b < i.length; b++) e = parseInt(i.charCodeAt(b) ^ Math.floor(255 * (a / h)), 10), f = 16 > e ? f + ("0" + e.toString(16)) : f + e.toString(16), a = (g * a + j) % h;
@19h
19h / parseMp4.js
Last active June 25, 2023 02:06
MP4 tkhd parser, works no matter how fucked your mp4 buffer is as long as it contains a tkhd box -- will give you dimensions (width, height), duration, creation time, modification time, track id, layer, alternate group, volume, the entire matrix, flags and version of the mp4 file.
const readU8 = (data, offset) =>
data[offset];
const readU16 = (data, offset) =>
(
data[offset] << 8
| data[offset + 1]
);
const readU24 = (data, offset) =>
@19h
19h / insta-dumper.js
Last active September 4, 2022 02:59
Instagram following followers network graph dumper crawler spider node.js api / private api
const { IgApiClient, IgLoginTwoFactorRequiredError } = require('instagram-private-api');
const inquirer = require('inquirer');
const Bluebird = require('bluebird');
const fs = require('fs');
process.env.IG_USERNAME = 'xxx';
process.env.IG_PASSWORD = 'xxx';
const ig = new IgApiClient();
@19h
19h / reset.js
Created February 19, 2013 22:51
Node.js — Clear Terminal / Console. Reset to initial state.
console.reset = function () {
return process.stdout.write('\033c');
}
@19h
19h / scrypt.js
Created February 20, 2013 21:10
A compact V8-ECMAScript ("Javascript") implementation of the Scrypt-hashing algorithm.
var j = void 0,
k = require("crypto");
function m(a) {
for (var b = a.length, c = Array(b), f = 0; f < b; f++) c[f] = a.charCodeAt(f);
return c
}
var p, q, s;
function t() {
@19h
19h / bloomFilter.js
Last active March 22, 2022 12:04
bloomFilter in Javascript.
var bloomFilter = (function(exports) {
var typedArrays = typeof ArrayBuffer !== "undefined";
var popcnt = function (v) {
v -= v >> 1 & 1431655765;
v = (v & 858993459) + (v >> 2 & 858993459);
return (v + (v >> 4) & 252645135) * 16843009 >> 24
}
var fnv_1a = function (v) {