Skip to content

Instantly share code, notes, and snippets.

#define HOOK_CALL(lib, name, size) \
static void (*_ ## name ## _hook)(void); \
void name (void) { \
void *args = __builtin_apply_args(); \
DBG("Calling %s", #name); \
if (!_ ## name ## _hook) { \
void *orig_p, *orig; \
void *hook = get_lib_hook(lib); \
orig = dlsym(RTLD_NEXT, #name); \
if (!orig) { \
@aragaer
aragaer / gist:1124829
Created August 4, 2011 09:27
item equip subroutine
def equip(name):
name = ' '.join(name)
item = get_inv_item(name, False)
if item.equipped:
print "%s is already equipped", name
return
if item.slot is None:
print "You equip %s" % name
power += item.bonus
@aragaer
aragaer / crypt32.diff
Created September 11, 2011 13:30
Fixes in crypt32
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c
index 75b0e12..8571c83 100644
--- a/dlls/crypt32/cert.c
+++ b/dlls/crypt32/cert.c
@@ -317,25 +317,28 @@ static BOOL CertContext_GetProperty(void *context, DWORD dwPropId,
break;
case CERT_KEY_IDENTIFIER_PROP_ID:
{
+ CRYPT_DATA_BLOB value;
+ DWORD size = sizeof(value);
int cnt = 0;
while (getenv("LD_PRELOAD")) {
fprintf(stderr, "l");
unsetenv("LD_PRELOAD");
if (cnt++ > 10)
break;
}
#define WIN32_LEAN_AND_MEAN
#define SECURITY_WIN32
#include <Windows.h>
#include <WinCrypt.h>
#include <Security.h>
#include <stdio.h>
#pragma comment(lib, "crypt32")
#define skip(...) do { printf(__VA_ARGS__); goto out; } while (0)
>>> for line in data:
... print "checking", line,
... m = re.search("latitude.*'(.*)'", line)
... if m:
... print m.group(1)
...
checking function geoip_country_code() { return 'RU'; }
checking function geoip_country_name() { return 'Russian Federation'; }
checking function geoip_city() { return 'Moscow'; }
checking function geoip_region() { return '48'; }
@aragaer
aragaer / gist:1401316
Created November 28, 2011 18:01
calc_jtt
def calc_jtt(start, end, now):
now = now.datetime()
end = end.datetime()
start = start.datetime()
hlen = (end - start).seconds/6.0
tnow = (now - start).seconds
return tnow/hlen
proxy = None
proxydict = urllib2.ProxyHandler().proxies
for type in ["https", "http", "socks"]:
if type not in proxydict:
continue
proxyline = proxydict[type]
schemalen = length(type + 3) # "<schema>://"
if proxyline[:schemalen] == "%s://" % type
proxyline = proxyline[schemalen:]
proxAddr, proxPort = proxyline.split(":")
#include <stdio.h>
int a() {
printf("a called\n");
return 0;
}
int b() {
printf("b called\n");
return 0;
@aragaer
aragaer / gist:1768287
Created February 8, 2012 11:25
1705 investigation
#include <stdio.h>
#include <math.h>
typedef unsigned long long int val_t;
val_t naive_calc(val_t n, val_t min) {
val_t k;
for (k = min; k < n; k++)
if (n / k == n / (k + 1))
return k;