Skip to content

Instantly share code, notes, and snippets.

View orisano's full-sized avatar

Nao Yonashiro orisano

View GitHub Profile
@orisano
orisano / given_d.py
Last active March 15, 2017 12:19
dが与えられた時にnに対して素因数分解を試みるやつ
from fractions import gcd
import random
from typing import Optional, Tuple
def given_d(n: int, e: int, d: int) -> Optional[Tuple[int, int]]:
ktot = e * d - 1
s = (ktot & -ktot).bit_length() - 1
t = ktot >> s
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="timer-wrapper">
<h1 id="timer" style="font-size: 74pt;">00:00</h1>
</div>
import clang.cindex
from clang.cindex import Index
def gen_stream_operator(cur):
if cur.kind.name == "STRUCT_DECL":
print("std::ostream& operator<<(std::ostream& os, const %s& rhs) {" % cur.displayname)
for child in cur.get_children():
if child.kind.name == "FIELD_DECL":
print(' os << "{member}:" << rhs.{member} << std::endl;'.format(member=child.displayname))
def array_sample(arr, k)
rng = Random.new
sample = Array.new k
sample[0] = arr[0]
(1...k).each {|i|
r = rng.rand(i + 1)
sample[i] = sample[r]
sample[r] = arr[i]
}
(k...arr.size).each {|i|
from pwn import *
context.arch = "amd64"
elf = ELF("./jmper")
if args["REMOTE"]:
HOST = "jmper.pwn.seccon.jp"
PORT = 5656
libc = ELF("./libc-2.19.so")
@orisano
orisano / decahook.h
Last active October 31, 2017 00:24
easy function hooking macros for DECAF - https://github.com/sycurelab/DECAF
/**
decahook.h
easy function hooking macros for DECAF.
support to stdcall only.
Copyright (c) 2016 Nao Yonashiro
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
*/
#ifndef DECAHOOK_H
#include <bits/stdc++.h> // {{{
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
@orisano
orisano / geteip.c
Last active August 14, 2016 07:11
#include "DECAF_types.h"
#include "DECAF_main.h"
#include "DECAF_callback.h"
#include "DECAF_callback_common.h"
#include "vmi_callback.h"
#include "utils/Output.h"
#include "DECAF_target.h"
#include "hookapi.h"
static plugin_interface_t geteip_interface;
@orisano
orisano / arc039_d.cpp
Last active September 29, 2017 16:12
ARC039D
#include <algorithm>
#include <utility>
#include <vector>
using Graph = std::vector<std::vector<int>>;
using Edge = std::pair<int, int>;
class BridgeHelper {
const Graph& graph;
std::vector<int> ord, low;
#include <algorithm>
#include <utility>
#include <vector>
using Graph = std::vector<std::vector<int>>;
using Edge = std::pair<int, int>;
class BridgeHelper {
const Graph& graph;
std::vector<int> ord, low;