This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Повертає монаду *) | |
let return x = Some x ;; | |
(* Перевіряє монаду на наявність значення та повертає результат | |
застосування функції до цього значення, інакше повертає *) | |
let (>>=) m f = | |
match m with | |
| None -> None | |
| Some x -> f x ;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ocaml | |
(* | |
Prerequisites: Findlib, Pcre, Cryptokit | |
Usage: openssl rsa -in privkey.pem -text | ./pem2ck.ml > privkey.cryptokit | |
*) | |
#use "topfind" ;; | |
#require "pcre" ;; | |
#require "cryptokit" ;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pkcs1v1pad key msg = | |
let blen = key.RSA.size/8 | |
and mlen = String.length msg in | |
let padlen = blen - mlen in | |
if padlen > 3 then begin | |
let res = String.make padlen (char_of_int 255) in | |
res.[0] <- (char_of_int 0); | |
res.[1] <- (char_of_int 1); | |
res.[padlen - 1] <- (char_of_int 0); | |
res ^ msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pkcs1v2pad key msg = | |
let blen = key.RSA.size/8 | |
and mlen = String.length msg | |
and zero = char_of_int 0 | |
and rnd = Random.string Random.secure_rng in | |
let padlen = blen - mlen in | |
if padlen > 3 then begin | |
let res = rnd padlen in | |
res.[0] <- (char_of_int 0); | |
res.[1] <- (char_of_int 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let strrev s = | |
let len = String.length s in | |
for i = 0 to ((len/2) - 1) do | |
let t = s.[i] in | |
s.[i] <- s.[len - i - 1]; | |
s.[len - i - 1] <- t | |
done; | |
s | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let (>>) x f = f x ;; | |
let hash = hash_string (Hash.sha256()) ;; | |
let sign_of_message key msg = | |
msg >> hash >> | |
(pkcs1v1pad key) >> | |
(RSA.sign key) >> | |
strrev | |
;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* ocamlfind ocamlopt -o exmpl -package curl -linkpkg exmpl.ml *) | |
open Printf | |
let _ = Curl.global_init Curl.CURLINIT_GLOBALALL | |
(* | |
************************************************************************* | |
** Aux. functions | |
************************************************************************* | |
*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Printf | |
type t = A of string * float | B of int * float | |
let l = [A ("a1", 0.); B (1, 1.); A ("a2", 1.1); A ("a3",1.2); B (2,1.1)] | |
let f = fun l -> | |
List.fold_left | |
(fun (a,b) it -> | |
match it,a,b with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/zsh | |
# Need flock | |
zmodload zsh/system | |
lfn=/tmp/.github | |
git=/usr/local/bin/git | |
prefix=/path/to/clones | |
secret=your_secret | |
user=mailnull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* ocamlfind ocamlopt -o scan -package unix,pcre scan.ml -linkpkg | |
Якщо знайти адресу кількості трупів сектоїдів, то забити склад | |
ніштяками можна, наприклад, так: | |
let addr = $sectoids | |
and pid = <XCOM pid> | |
and ch = open_out "cmd.gdb" in | |
for i = 0 to 35 do | |
Printf.fprintf ch "set {int}(0x%X + 4*%d) = 99999\n" addr i |
OlderNewer