Skip to content

Commit 47f1376

Browse files
retrocpugeekclaude
andcommitted
Add MIPS32 big-endian shellcode test
test_shellcode.py only exercised little-endian MIPS. Add a big-endian counterpart (MIPS32EB_LIN) so MIPS BE emulation is covered too. The shellcode is the byte-swapped form of MIPS32EL_LIN (instruction words reversed, '/bin/sh' string left intact) and is run with endian=QL_ENDIAN.EB, reusing the existing graceful_execve EXIT hook to end emulation cleanly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 46f2d47 commit 47f1376

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

tests/test_shellcode.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
sys.path.append("..")
1010

1111
from qiling import Qiling
12-
from qiling.const import QL_ARCH, QL_OS, QL_INTERCEPT, QL_VERBOSE
12+
from qiling.const import QL_ARCH, QL_OS, QL_ENDIAN, QL_INTERCEPT, QL_VERBOSE
1313

1414

1515
# test = bytes.fromhex('cccc')
@@ -22,6 +22,13 @@
2222
2f7368
2323
''')
2424

25+
# big-endian counterpart of MIPS32EL_LIN: the instruction words are byte-swapped
26+
# while the trailing '/bin/sh' string is left as-is
27+
MIPS32EB_LIN = bytes.fromhex('''
28+
2806ffff04d0ffff2805ffff27e410012484f00f24020fab0101010c2f62696e
29+
2f7368
30+
''')
31+
2532
X86_WIN = bytes.fromhex('''
2633
fce8820000006089e531c0648b50308b520c8b52148b72280fb74a2631ffac3c
2734
617c022c20c1cf0d01c7e2f252578b52108b4a3c8b4c1178e34801d1518b5920
@@ -105,6 +112,13 @@ def test_linux_mips32(self):
105112
ql.os.set_syscall('execve', graceful_execve, QL_INTERCEPT.EXIT)
106113
ql.run()
107114

115+
def test_linux_mips32eb(self):
116+
print("Linux MIPS 32bit EB Shellcode")
117+
ql = Qiling(code=MIPS32EB_LIN, archtype=QL_ARCH.MIPS, ostype=QL_OS.LINUX, endian=QL_ENDIAN.EB, verbose=QL_VERBOSE.OFF)
118+
119+
ql.os.set_syscall('execve', graceful_execve, QL_INTERCEPT.EXIT)
120+
ql.run()
121+
108122
# This shellcode needs to be changed to something non-blocking
109123
def test_linux_arm(self):
110124
print("Linux ARM 32bit Shellcode")

0 commit comments

Comments
 (0)