Skip to content

Instantly share code, notes, and snippets.

View shelajev's full-sized avatar

Oleg Šelajev shelajev

View GitHub Profile
IDENTIFICATION DIVISION.
PROGRAM-ID. KECCAK-Wrapper-struct.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.
01 LNK-KECCAK.
// load C Code
var cobol = Polyglot.evalFile("llvm", "KECCAK.so");
(function SHA3_256(sha_input, sha_input_length, sha_output) {
cobol.KECCAK__Wrapper__struct({
LNK_KECCAK_RATE: 1088,
LNK_KECCAK_CAPACITY: 512,
LNK_KECCAK_INPUT: sha_input,
LNK_KECCAK_INPUT_BYTE_LEN: sha_input_length,
CALL WS-SHA3-256-JS-POINTER USING WS-INPUT
WS-INPUT-BYTE-LEN
WS-SHA3-256-OUTPUT
END-CALL
@shelajev
shelajev / pol.cob
Last active October 15, 2020 13:45
*> interoperability fields
01 WS-SHA3-256-JS-POINTER PROGRAM-POINTER.
01 WS-JS PIC X(3).
01 WS-SHA3-256-JS-FILENAME PIC X(50).
MOVE Z'js' TO WS-JS.
MOVE Z'SHA3-256.js' TO WS-SHA3-256-JS-FILENAME.
*> get javascript function
CALL STATIC "polyglot_eval_file" using
CALL "SHA3-256" USING WS-INPUT
WS-INPUT-BYTE-LEN
WS-SHA3-256-OUTPUT
END-CALL
@shelajev
shelajev / Sensitive.java
Last active April 27, 2020 11:40
Reflection examples
package org.example;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import java.lang.reflect.Method;
public class Sensitive extends Application {
import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.Certificate;
import java.io.*;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLPeerUnverifiedException;
public class Curl {
import java.util.List;
import java.util.Arrays;
import org.graalvm.polyglot.*;
public class MyClass {
public static void main(String[] args) {
try (Context context = Context.newBuilder().allowAllAccess(true).build()) {
context.eval("python",
#define WASM_EXPORT __attribute__((visibility("default")))
WASM_EXPORT
int main() {
return 42;
}
@shelajev
shelajev / fact.wasm
Last active November 13, 2019 15:02
get_local 0
i64.eqz
if (result i64)
i64.const 1
else
get_local 0
get_local 0
i64.const 1
i64.sub
call 0