Skip to content

Instantly share code, notes, and snippets.

View knknkn1162's full-sized avatar

Kenta Nakajima knknkn1162

View GitHub Profile
@knknkn1162
knknkn1162 / res.txt
Last active September 10, 2022 03:43
# strace python3 test.py
execve("/usr/bin/python3", ["python3", "test.py"], 0x7ffdc838e258 /* 8 vars */) = 0
brk(NULL) = 0x555a1e400000
arch_prctl(0x3001 /* ARCH_??? */, 0x7fffc8823cb0) = -1 EINVAL (Invalid argument)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb18ac73000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=6447, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 6447, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fb18ac71000
close(3) = 0
$ curl --trace /dev/stdout -XPOST -H "Accept: application/json" 'http://httpbin.org/post?ss=ok'
== Info: Trying 52.87.105.151:80...
== Info: Connected to httpbin.org (52.87.105.151) port 80 (#0)
=> Send header, 99 bytes (0x63)
0000: 50 4f 53 54 20 2f 70 6f 73 74 3f 73 73 3d 6f 6b POST /post?ss=ok
0010: 20 48 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a HTTP/1.1..Host:
0020: 20 68 74 74 70 62 69 6e 2e 6f 72 67 0d 0a 55 73 httpbin.org..Us
0030: 65 72 2d 41 67 65 6e 74 3a 20 63 75 72 6c 2f 37 er-Agent: curl/7
0040: 2e 37 39 2e 31 0d 0a 41 63 63 65 70 74 3a 20 61 .79.1..Accept: a
0050: 70 70 6c 69 63 61 74 69 6f 6e 2f 6a 73 6f 6e 0d pplication/json.
$ curl -v http://localhost:8080
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
python -c "import itertools; print('\n'.join([''.join(lst) for lst in itertools.permutations(list('リコリスリコイル'))]))" | group | %{$_.Name}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t
#include <math.h>
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
int get_int100(void) {
@knknkn1162
knknkn1162 / container.log
Last active February 3, 2020 11:31
`strace -ff -o test.log systemd-nspawn --directory=debian sleep infinity`
close(8) = 0
close(5) = 0
close(10) = 0
close(12) = 0
rt_sigaction(SIGHUP, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7fc03512c5f0}, NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7fc03512c5f0}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7fc03512c5f0}, NULL, 8) = 0
rt_sigaction(SIGILL, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7fc03512c5f0}, NULL, 8) = 0
rt_sigaction(SIGTRAP, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7fc03512c5f0}, NULL, 8) = 0
rt_sigaction(SIGABRT, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7fc03512c5f0}, NULL, 8) = 0
./scripts/travis.sh
spawn ssh -o UserKnownHostsFile /dev/null root@localhost -p 5107
The authenticity of host '[localhost]:5107 ([127.0.0.1]:5107)' can't be established.
ECDSA key fingerprint is SHA256:S1GDtmoFHR4WvJVy7RJiW6jWWmkldr50sSuXdFNghIM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:5107' (ECDSA) to the list of known hosts.
root@localhost's password:
# insmod keystone-driver.ko
# cd tests; ./tests.ke
Verifying archive integrity... All good.
// lib/sbi/sbi_hart.c
// sbi_hart_switch_mode(hartid, scratch->next_arg1, scratch->next_addr, scratch->next_mode, false);
void __attribute__((noreturn))
sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
unsigned long next_addr, unsigned long next_mode,
bool next_virt)
{
unsigned long val;
switch (next_mode) { // scratch->next_mode
@knknkn1162
knknkn1162 / fw_base.S
Last active October 17, 2019 03:06
hart with hart_id==0
.align 3
.section .entry, "ax", %progbits
.globl _start
.globl _start_warm
_start:
csrr a6, CSR_MHARTID // assume that hart_id=0
// The condition `zero < a6=0` is false
blt zero, a6, _wait_relocate_copy_done
/* Save load address */
@knknkn1162
knknkn1162 / opensbi_linux.sh
Created October 15, 2019 23:59
OpenSBI; Linux Kernel Payload
$ make CROSS_COMPILE=riscv64-unknown-elf- PLATFORM=qemu/virt FW_PAYLOAD_PATH=../linux-stable/arch/riscv/boot/Image
CC lib/sbi/riscv_asm.o
CC lib/sbi/riscv_atomic.o
AS lib/sbi/riscv_hardfp.o
CC lib/sbi/riscv_locks.o
CC lib/sbi/riscv_unpriv.o
CC lib/sbi/sbi_console.o
CC lib/sbi/sbi_ecall.o
CC lib/sbi/sbi_emulate_csr.o
CC lib/sbi/sbi_fifo.o