Skip to content

Instantly share code, notes, and snippets.

View moyix's full-sized avatar

Brendan Dolan-Gavitt moyix

View GitHub Profile
@moyix
moyix / shadowstack.c
Last active March 23, 2022 17:43
Example of using a constructor to set up the shadow callstack and assign gs appropriately
#include <stdio.h>
#include <asm/prctl.h>
#include <sys/prctl.h>
#include <stdlib.h>
// Compile with: clang-8 -fsanitize=shadow-call-stack shadowstack.c -o shadowstack
int arch_prctl(int code, unsigned long *addr);
void __attribute__ ((constructor)) __attribute__((no_sanitize("shadow-call-stack"))) setupgs()
@moyix
moyix / tiffcrop.c
Created March 22, 2022 19:58
Buggy code from libtiff
static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf,
uint32 imagelength, uint32 imagewidth,
uint32 tw, uint32 tl,
uint16 spp, uint16 bps)
{
int i, status = 1, sample;
int shift_width, bytes_per_pixel;
uint16 bytes_per_sample;
uint32 row, col; /* Current row and col of image */
uint32 nrow, ncol; /* Number of rows and cols in current tile */
@moyix
moyix / codex_commands.txt
Created March 11, 2022 16:18
Commands executed by Codex across 100 five-minute runs in a Linux VM
288
91 {
42 y
40 ")
40 """
34 #!/usr/bin/env python
33 import numpy as np
33 # -*- coding: utf-8 -*-
31 ubuntu
28 Authentication failure
@moyix
moyix / async_lsremote.py
Last active July 20, 2022 17:42
Retrieve reflist for a repository on Github using httpx and asyncio
#!/usr/bin/env python
import os
import itertools
import asyncio
import sys
import httpx
import time
import random
from binascii import crc32
@moyix
moyix / getrepo.sh
Created February 18, 2022 02:53
Geez this is awful
#!/bin/bash
DB_TIMEOUT=10000
if [[ $# -ne 3 ]]; then
echo "getrepo.sh name url jobslot"
exit 1
fi
jobslot="$3"
@moyix
moyix / gcasm.py
Created February 15, 2022 01:21
Assembler and demo program for the (made-up) THX-1138 CPU used by the gift card reader in NYU's Application Security Course
#!/usr/bin/env python3
# An assembler for the THX-1138 CPU used in NYU AppSec's gift card reader.
# From giftcard.h:
# programs operate on the message buffer
# note!! it is the gift card producers job to make sure that
# programs in the gift card are VALID
# each "instruction" is 3 bytes
# arithmetic instructions set the zero flag if the result is 0
# opcode (1 byte) arg1 (1 byte) arg2 (1 byte)
@moyix
moyix / sample_output_t0.0_p0.0.csv
Created February 13, 2022 23:31
GPT-NeoX-20B arithmetic, raw data for a parameter sweep over temperature and top-p
question a op b real guess correct digits_correct ends_correct rel_error norm_edit
What is 6154 * 24858? 6154 * 24858 152976132 159945132 False 6 2 0.045556126363555854 0.6666666666666667
What is 9216 * 4886? 9216 * 4886 45029376 44011776 False 4 2 0.022598580979669804 0.5
What is 12112 * 22269? 12112 * 22269 269722128 269917248 False 4 2 0.000723411169290493 0.4444444444444444
What is 14781 * 13069? 14781 * 13069 193172889 199179969 False 5 2 0.03109691029158859 0.5555555555555556
What is 21756 * 16? 21756 * 16 348096 348096 True 6 2 0.0 1.0
What is 13879 * 25528? 13879 * 25528 354303112 345595352 False 2 2 0.02457714794218347 0.33333333333333337
What is 25765 * 14098? 25765 * 14098 363234970 366455210 False 3 2 0.008865445967385794 0.33333333333333337
What is 1358 * 28411? 1358 * 28411 38582138 38254558 False 3 2 0.008490457423588086 0.375
What is 11654 * 16026? 11654 * 16026 186767004 192725124 False 3 2 0.0319013523395171 0.33333333333333337
@moyix
moyix / magnitude.csv
Created February 13, 2022 03:42
GPT-NeoX-20B arithmetic at different orders of magnitude (raw data)
We can't make this file beautiful and searchable because it's too large.
question,a,op,b,real,guess,correct,digits_correct,ends_correct,rel_error,norm_edit
What is 4 + 2?,4,+,2,6,6,Yes,1,2,0.0,1.0
What is 7 + 9?,7,+,9,16,16,Yes,2,2,0.0,1.0
What is 9 + 9?,9,+,9,18,18,Yes,2,2,0.0,1.0
What is 8 + 6?,8,+,6,14,14,Yes,2,2,0.0,1.0
What is 1 + 8?,1,+,8,9,9,Yes,1,2,0.0,1.0
What is 5 + 5?,5,+,5,10,10,Yes,2,2,0.0,1.0
What is 4 + 3?,4,+,3,7,7,Yes,1,2,0.0,1.0
What is 5 + 5?,5,+,5,10,10,Yes,2,2,0.0,1.0
What is 1 + 5?,1,+,5,6,6,Yes,1,2,0.0,1.0
@moyix
moyix / arith1000_t0.1_k0_p0.0_results.txt
Created February 10, 2022 21:52
Data files for GPT-NeoX-20B arithmetic (100 and 1000 questions)
Question Real Guess Correct? RelErr Digits
What is 18857 - 592? 18265 18265 Yes 0.0% 5/5
What is 30752 - 3087? 27665 27365 No 1.1% 4/5
What is 2241 + 19873? 22114 22114 Yes 0.0% 5/5
What is 5412 + 10169? 15581 15581 Yes 0.0% 5/5
What is 11831 - 9178? 2653 3153 No 18.8% 2/4
What is 1701 * 19933? 33906033 33953373 No 0.1% 4/8
What is 11648 + 17851? 29499 30509 No 3.4% 1/5
What is 29253 - 6202? 23051 22151 No 3.9% 3/5
What is 27365 + 24989? 52354 53554 No 2.3% 3/5
@moyix
moyix / neox_20B_math.txt
Created February 10, 2022 16:16
Results of asking GPT-NeoX-20B some math questions
Question Real Guess Correct?
What is 28142 + 16738? 44880 45180 No
What is 9690 - 18711? -9021 -9321 No
What is 10365 - 11572? -1207 -1207 Yes
What is 12420 + 20678? 33098 32998 No
What is 17051 + 29637? 46688 46488 No
What is 10052 * 6572? 66061744 65655584 No
What is 9276 - 28689? -19413 -18213 No
What is 7924 - 12216? -4292 -4292 Yes
What is 1867 * 23864? 44554088 4427444 No