Skip to content

Instantly share code, notes, and snippets.

View segfo's full-sized avatar

segfo segfo

View GitHub Profile
void EntryPoint_1(){
  int stack[6];
stack[5] = 0x80534e0; // _deh_end
stack[4] = 0x80534c8; // _deh_begin
stack[3] = 0x80534c8; // _minfo_end
stack[2] = 0x80534a8; // _minfo_begin
stack[1] = 0x8050100; // _slot
stack[0] = 0x1; // version
_d_dso_registry(&stack);
segfo@AAAA41414141:/mnt/c/Users/segfo/Desktop$ gdb ./a.out
gdb-peda$ start
// 省略
gdb-peda$ vmmap
Start              End                Perm      Name
0x00400000         0x00401000         rwx-      /mnt/c/Users/segfo/Desktop/a.out
0x00600000         0x00601000         r---      /mnt/c/Users/segfo/Desktop/a.out
0x00601000         0x00602000         rw--      /mnt/c/Users/segfo/Desktop/a.out
0x00007fe048430000 0x00007fe0485ea000 r-x-      /lib/x86_64-linux-gnu/libc-2.19.so

0x00007fe0485ea000 0x00007fe0485f2000 ---- /lib/x86_64-linux-gnu/libc-2.19.so

@segfo
segfo / SEGV_OS_Dependent.d
Last active September 2, 2016 13:17
OSによってSEGVするコード
import std.stdio;
void main(){
string s="hogehoge";
ubyte[] sb=cast(ubyte[])s;
sb[1]='A';
writeln(cast(string)sb);
}
@segfo
segfo / testRegex.py
Created December 6, 2016 15:20
testRegex.py
# -*- coding: utf-8 -*-
import re
regexPatt = r".*=([0-9]+)"
regexPatt1 = regexPatt[0:regexPatt.find("(")]
regexPatt2 = regexPatt[regexPatt.find("("):regexPatt.find(")")+1]
regexPatt = regexPatt1+regexPatt2
print "正規表現:"+regexPatt
text = "hogefuga=1234\nfugafuga=8882\nsusono"
@segfo
segfo / fsbLeakElfTest.c
Last active December 23, 2016 14:45
fsbを利用したELFファイルのリーク
#include <stdio.h>
int main()
{
char buf[81];
printf("plz, tell me yo name: ");
buf[read(0,buf, sizeof(buf)-1)]='\0';
printf("Hi, ");
@segfo
segfo / expression.d
Created December 28, 2016 13:47
演算子評価順序
import std.stdio;
void main(){
int i=0;
(i = 2) = ++i * i++ + i;
writefln("i = %d",i);
}
@segfo
segfo / dupDel.py
Created January 14, 2017 02:19
重複したものを削除
#!/usr/bin/env python
#-*- coding: utf-8 -*-
a = ["abc","def","cdf","abc","abb"]
b = ["abc","def","cdf","abb","zbjl","klgjh","43whyur"]
def dupDel(seq):
seen = set()
seen_add = seen.add
#include<stdio.h>
int main(){
// 例のテーブル
char tbl[]={
0x4,0xb2,0xf,0x47,0x33,0x84,0x7f,0xdd,0x44,0xbd,0xd6,0x98,0xad,
0x83,0xd3,0x34,0x23,0xa1,0x65,0x88,0x73,0xdb,0x95,0xf0
};
// randで生成される数値列を固定する
srand(0);
@segfo
segfo / crossref_struct.c
Last active March 11, 2018 06:14
相互参照する構造体の書き方
// タグ名だけ書く。
struct Context;
// ステートを管理するためのContext構造体を引数に持ってコールバックを呼びたい
// 例えば非同期関数がエラーだった時とかのコールバックや
// オブザーバーパターンを実装するときとかによく使うやつ。
typedef struct Callback
{
uintmax_t state; //状態の保存
void (*onError)(struct Context* ctx); //ここでContextを渡す関数ポインタを定義する
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
typedef struct testVtbl{
int hoihoi[10];
void (*start)(void);
void (*end)(void);
}TestVTbl;