man bcBC 的高级程度超乎我的想象 🌚...
触手可得的高级数学计算 DSL
define loop_print (c) { while (1) print(c); }loop_print(2333)
while (1)
print "烫" /* 23333 */
for (i = 1; i <= 100; i++) {
if (i % 3 == 0) { /* Fizz */
print "Fizz!\n"
continue
}
if (i % 5 == 0) { /* Buzz */
print "Buzz!\n"
} else {
print i, "\n"
}
}
还有个
你可以这样算
(有点高级啊,UNIX 工程师都是这么玩的.... 我还是选择 bc 😂
dc is a reverse-polish desk calculator which supports unlimited precision arithmetic.
(记住比 bc 低级就是了)(滑稽)你可以这样算
1 + 2 + 3 * 3
2
1
+
3
3
*
+
p
等于
(+ (+ 2 1) (* 3 3))
(有点高级啊,UNIX 工程师都是这么玩的.... 我还是选择 bc 😂
Forwarded from duangsues.is_a? SaltedFish
##### Gathering file information...真好用
RUN: /home/dse/rd/bin/retdec-fileinfo -c /home/dse/liba.so.c.json --similarity /home/dse/liba.so --no-hashes=all --crypto /home/dse/rd/bin/../share/retdec/support/generic/yara_patterns/signsrch/signsrch.yara --max-memory-half-ram
Input file : /home/dse/liba.so
File format : ELF
File class : 32-bit
File type : DLL
Architecture : x86 (or later and compatible)
Endianness : Little endian
Detected tool : gold (1.11) (linker), .note section heuristic
Detected tool : GCC (4.8) (compiler), .comment section heuristic
Detected tool : GCC (4.9) (compiler), .comment section heuristic
Original language : C++
// Address range: 0x8a1 - 0x8c4原来的版本:
int32_t BEL(void) {
// 0x8a1
int32_t v1;
return 4 * (v1 + 2) / 3 | 1;
}
function BEL (.text) {
0x8a1: push ebp
0x8a2: ebp = esp ; begin logic
0x8a4: eax = *(ebp + 8) ; v1: *(bp + 8)
0x8a7: ecx = eax + 2 ; cx := ax + 2
0x8aa: edx = 1431655766 "VUUU" ; dx := 0x55555556
0x8af: eax = ecx ; ax := ax + 2 ; cx
0x8b1: edx:eax = eax * edx ; dx, ax := ax * dx ; dx = ax * dx
0x8b3: eax = ecx ; ax := cx (ax + 2)
0x8b5: eax >>= 31 ; ax := ax shr 0x1f
0x8b8: edx -= eax ; dx := dx - ax
0x8ba: eax = edx ; ax := dx (ax * dx - ax)
0x8bc: eax <<= 2 ; ax := ax shl 0x2
0x8bf: eax += 1 ; ax++
0x8c2: pop ebp
0x8c3: ret ; give control back to caller
}
这里很清楚(反正我也看不懂这是做什么(int BEL(int a) {
// dx = 0x55555556
// ax = (int32_t) a1
// cx = ax + 2
// ax = cx // ax + 2
// dx = ax * dx // (ax + 2) * 0x55555556
// ax = cx // ax + 2
// ax = ax >> 31 // 0x1f // ax + 2 >> 31
// dx -= ax // (ax + 2) * 0x55555556 - ax + 2 >> 31
// ax = dx // ax * dx - ax
// ax << 2 // ax * 4 // 现在估计没人用这种位运算“优化”了
// ((ax + 2) * 0x55555556 - ax + 2 >> 31) * 4
// ax++
return ((a + 2) * 0x55555556 - ax + 2 >> 31) * 4
}
有没有 可能 是 这样 呢?在测试 中(
如果真的是
如果真的是
int BEL(void); 那 就应该 是 (2 * 0x55555556 - ax + 2 >> 31)*4 吧(我 Python ctypes 试了一下,
从 1 开始遵循一个规律: 每三个数加四
但反编译出来的明显不能用...
for i in range(0, 1000):
print(c.BEL(i))
1
5
5
5
9
9
9
13
13
13
17
17
17
从 1 开始遵循一个规律: 每三个数加四
但反编译出来的明显不能用...
irb(main):021:0> def bel n
irb(main):022:1> 4 * (n + 2) / 3 | 1
irb(main):023:1> end
(0..1000).each { |n| puts bel n }
3
5
5
7
9
9
11
13
13
15
17
17
19
def bel_asm(n)
ax = n
cx = ax + 2
dx = 1431655766
ax = cx
dx, ax = ax * dx
ax = cx
ax >>= 31
dx -= ax
ax = dx
ax <<= 2
ax += 1
return ax
end