Skip to content

Instantly share code, notes, and snippets.

View zjuchenyuan's full-sized avatar

ChenYuan zjuchenyuan

View GitHub Profile
@christianroman
christianroman / test.py
Created May 30, 2013 16:02
Bypass Captcha using 10 lines of code with Python, OpenCV & Tesseract OCR engine
import cv2.cv as cv
import tesseract
gray = cv.LoadImage('captcha.jpeg', cv.CV_LOAD_IMAGE_GRAYSCALE)
cv.Threshold(gray, gray, 231, 255, cv.CV_THRESH_BINARY)
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)
tesseract.SetCvImage(gray,api)
print api.GetUTF8Text()
@quark-zju
quark-zju / gdb-trace.py
Last active December 31, 2023 14:14
Trace all function calls using gdb
#!/usr/bin/env python
try:
import gdb
inside_gdb = True
except ImportError:
inside_gdb = False
if inside_gdb:

Exploiting Lua 5.1 on 32-bit Windows

The following Lua program generates a Lua bytecode program called ignore-unsigned-sga.fnt, which in turn loads a DLL from within an extremely locked down Lua 5.1 sandbox in a program called RelicCOH2.exe. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

if string.dump(function()end):sub(1, 12) ~= "\27Lua\81\0\1\4\4\4\8\0" then
  error("This generator requires a 32-bit version of Lua 5.1")
end

local function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed
@allex
allex / gist:11203573
Last active December 5, 2023 07:27
Ubuntu 安装中文字体

环境 (Environment)

版本:Ubuntu 14.04 LTS 默认语言:English(United States)

安装 (Setup)

Debian 和 Ubuntu 下对中文支持比较好的字体有: fonts-droid、ttf-wqy-zenhei 和 ttf-wqy-microhei 等,除了文泉驿系列字体外,比较流行的免费中文字体还有文鼎提供的楷体和上海宋,包名分别是: fonts-arphic-ukai 和 fonts-arphic-uming。

@sergiotapia
sergiotapia / md5-example.go
Last active December 5, 2023 03:53
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@gerbenvandijk
gerbenvandijk / OldBrowser.js
Created November 19, 2013 09:56
Detect if the user has an old browser and if so, it inserts a friendly notification that not all features on the site will work, and that an upgrade is recommended.
// The code - first bit is all the UserAgent library.
(function(wndw) {
var Browsers, OS, Platform, Versions, browser_name, browser_version, os, platform;
Versions = {
Firefox: /firefox\/([\d\w\.\-]+)/i,
IE: /msie\s([\d\.]+[\d])/i,
Chrome: /chrome\/([\d\w\.\-]+)/i,
Safari: /version\/([\d\w\.\-]+)/i,
Ps3: /([\d\w\.\-]+)\)\s*$/i,
Psp: /([\d\w\.\-]+)\)?\s*$/i
@mgeeky
mgeeky / vm-auto-snapshot.sh
Last active July 24, 2022 20:15
Script to manage auto-snapshots for specified VirtualBox VM. Able to rotate snapshots, create, restore and delete ones.
#!/bin/bash
# vim: ts=4 sw=4 et
#
# Auto-snapshotting script intended to be cron'ed,
# taking automatic snapshots of particular VM, logging that actions,
# and providing means of restoring specific snapshots.
# Included with functionality of rotating them (like logrotate).
#
# Example cron entry for this script:
@0xYYY
0xYYY / RUG.md
Last active October 14, 2021 04:09
SaturnBeam Finance - A 10M USD RUG on Moonriver

A 10M USD RUG on Moonriver

Warning: The following analysis may contain incorrect information, please verify everything yourself before believing in these info.

Would be nice to have someone better in on-chain analysis to double check these.

Background

SatrunBeam Finance was a yield aggregator on Moonriver, a EVM-Compatible parachain on Kusama in the Polkadot ecosystem.

It attracted several millions of liquidity within a month. The team is anon and they claimed that the contracts are audited by BitRise whose domain name was only registered on 2022-08-22 (https://who.is/whois/bitriseaudits.com). And the contracts were never actually verified on the block explorer.

@amitsaha
amitsaha / pi_mp.py
Created March 14, 2012 12:02
Parallel Pi Calculation using Python's multiprocessing module
''' listing 6: pi_mp.py
Multiprocessing based code to estimate the value of PI
using monte carlo sampling
Ref: http://math.fullerton.edu/mathews/n2003/montecarlopimod.html
Uses workers:
http://docs.python.org/library/multiprocessing.html#module-multiprocessing.pool
'''
import random
// 程序启动器[win32]
// 一个小玩意,作用就是读取与 exe 同名的 .config 文件,并逐条并行执行,不显示窗口
// 以 # 打头的行忽略
// 用于开机挂载一些自带 cmd 窗口的程序
// 自用 vs2017 编译测试通过
// ver 1.1
// 一个新语法:@命令 可以等待此命令结束后再继续运行
// 例如 @ping 127.1 -n 3 等待3秒