Add r2bolt webui PoC ##webui
This commit is contained in:
parent
58ca9f46b9
commit
4573e545fd
|
@ -0,0 +1,3 @@
|
|||
PWD=$(shell pwd)
|
||||
all:
|
||||
r2 -qcq -e http.sandbox=false -e http.root=${PWD} -c=H -
|
|
@ -0,0 +1,38 @@
|
|||
<html>
|
||||
<script src="r2.js"></script>
|
||||
<script>
|
||||
let cflags = '';
|
||||
let compiler = "gcc -S";
|
||||
const $ = (x) => document.getElementById(x);
|
||||
function compile() {
|
||||
const cc = btoa($('compiler').value);
|
||||
const cs = btoa($('source').value);
|
||||
const cmd = `""!!sh ./r2bolt.sh '' '${cs}'`;
|
||||
r2.cmd(cmd, (res) => {
|
||||
if (res.trim()) {
|
||||
$('output').innerHTML = res;
|
||||
}
|
||||
});
|
||||
}
|
||||
compile();
|
||||
</script>
|
||||
<body>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<input type="button" value="r2bolt" onclick="javascript:compile()"></input>
|
||||
<input id="compiler" value="gcc -S" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<textarea rows=20 id="source" onkeyup="compile()">
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
return 1 + 2;
|
||||
}
|
||||
</textarea></td>
|
||||
<td><div id="output" style="font-size:0.7em;font-family:Courier;white-space: pre;"></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
# arg1 = compiler+flags
|
||||
# arg2 = base64(source)
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
CC="gcc -S"
|
||||
else
|
||||
CC="`rax2 -D $1`"
|
||||
fi
|
||||
if [ -z "$2" ]; then
|
||||
CS="main() {}"
|
||||
else
|
||||
CS="`rax2 -D $2`"
|
||||
fi
|
||||
|
||||
USE_R2=1
|
||||
if [ "$USE_R2" = 1 ]; then
|
||||
echo "$CS" > .a.c
|
||||
gcc -o a.out .a.c
|
||||
# r2 -qcq -e scr.color=0 -e asm.lines=0 -e asm.bytes=0 -c'pD $SS@$S;aa;agf' a.out
|
||||
r2 -qcq -e scr.color=0 -e asm.lines=0 -e asm.bytes=0 -c'af;agf' a.out
|
||||
rm -f .a.c a.out
|
||||
else
|
||||
echo "$CS" > .a.c
|
||||
$CC .a.c
|
||||
cat .a.s
|
||||
rm -f .a.s .a.c
|
||||
fi
|
Loading…
Reference in New Issue