Skip to content

Instantly share code, notes, and snippets.

@inaz2
inaz2 / mylib.c
Last active January 25, 2016 05:13
CodeGate 2015 beef_steak (Pwnable 400) / 2016/01/23 katagaitai CTF勉強会 - 関東|med
#include <stdlib.h>
__attribute__((constructor)) void init() {
char *args[] = {"/bin/sh", NULL};
execve(args[0], args, NULL);
}
@inaz2
inaz2 / result.txt
Last active January 29, 2016 02:41
Using C function from Python ctypes
$ gcc -shared -fPIC trial_division.c -o trial_division.so
$ time python uselib.py
14115591195084627607
14115591195084627607 = 3667917713 * 3848393639
real 0m30.045s
user 0m30.008s
sys 0m0.012s
@inaz2
inaz2 / code.txt
Created January 24, 2016 14:41
time for 2^32 loops in C, golang, Python
$ cat loop.c
int main()
{
long i;
for (i=0; i<(1L<<32); i++) {
}
return 0;
}
$ cat loop.go
$ python wyvern.py
[+] secret length = 28
[+] secret = dAAAAAAAAAAAAAAAAAAAAAAAAAAA
[+] secret = drAAAAAAAAAAAAAAAAAAAAAAAAAA
[+] secret = dr4AAAAAAAAAAAAAAAAAAAAAAAAA
[+] secret = dr4gAAAAAAAAAAAAAAAAAAAAAAAA
[+] secret = dr4g0AAAAAAAAAAAAAAAAAAAAAAA
[+] secret = dr4g0nAAAAAAAAAAAAAAAAAAAAAA
[+] secret = dr4g0n_AAAAAAAAAAAAAAAAAAAAA
[+] secret = dr4g0n_oAAAAAAAAAAAAAAAAAAAA
@inaz2
inaz2 / client.c
Created March 4, 2016 08:20
IPv6 server & client in C
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
void ping(int s, char *message)
{
char buf[8192];
$ python solve.py
ERROR | 2016-03-16 15:42:22,827 | simuvex.procedures.syscalls | no syscall 202 for arch AMD64
ERROR | 2016-03-16 15:42:22,830 | simuvex.procedures.syscalls | no syscall 202 for arch AMD64
ERROR | 2016-03-16 15:42:22,833 | simuvex.procedures.syscalls | no syscall 202 for arch AMD64
WARNING | 2016-03-16 15:42:22,901 | simuvex.vex.irsb | <SimIRSB 0x107132b> hit an error while analyzing statement 19
Traceback (most recent call last):
File "/home/user/tmp/angr-doc/ENV/local/lib/python2.7/site-packages/simuvex/vex/irsb.py", line 92, in _handle_irsb
self._handle_statements()
File "/home/user/tmp/angr-doc/ENV/local/lib/python2.7/site-packages/simuvex/vex/irsb.py", line 208, in _handle_statements
s_stmt = translate_stmt(self.irsb, stmt_idx, self.last_imark, self.state)
@inaz2
inaz2 / digger.py
Last active April 19, 2016 06:34
investigate IPv6 status of Alexa Top Sites
import subprocess
with open('top-1m.csv') as f:
for line in f:
idx, domain = line.rstrip().split(',')
try:
result = subprocess.check_output(["dig", domain, "A"])
result_a = 0 if 'ANSWER: 0' in result else 1
except subprocess.CalledProcessError:
result_a = 2
package application;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javafx.application.Application;
@inaz2
inaz2 / FileInfo.java
Last active April 26, 2016 11:37
SHA-1 Calculator FXML (JavaFX+FXML) / http://inaz2.hatenablog.com/entry/2016/04/26/203503
package application;
import javafx.beans.property.SimpleStringProperty;
public class FileInfo {
private final SimpleStringProperty path = new SimpleStringProperty();
private final SimpleStringProperty sha1sum = new SimpleStringProperty();
public FileInfo(String path, String sha1sum) {
setPath(path);