Skip to content

Commit

Permalink
issue #46 update doc strings and reversing
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyleite committed Mar 10, 2022
1 parent 3f3ae9d commit 9d6b77b
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 44 deletions.
92 changes: 55 additions & 37 deletions doc/source/reversing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,49 +61,67 @@ Display information of instructions asm internet is required for help us.
.......
bh_replacestring
----------

bh_intel
--------

Sets the debugger disassembly style to displays the disassembly code in Intel style.
Display information of instructions asm internet is required for help us.

.. note::

Usage

``bh_asminfo`` [ asm instruction ]

.. code-block:: bash
$ bh_asminfo mov
mov
|Code |Mnemonic |Description |
|88 / r |MOV r/m8, r8 |Move r8 to r/m8 |
|89 / r |MOV r/m16, r16 |Move r16 to r/m16 |
|89 / r |MOV r/m32, r32 |Move r32 to r/m32 |
|8A / r |MOV r8, r/m8 |Move r/m8 to r8 |
|8B / r |MOV r16, r/m16 |Move r/m16 to r16 |
.......
.......
.......
bh_zerostring
----------

Replace with zero bytes in block or common file.

.. note::

Usage
``bh_intel`` [on | off]

``bh_zerostring`` [ file ] [ string to replace ]

.. code-block:: bash
$ bh_intel on
$ gdb ./input
....
(gdb) disassemble main
Dump of assembler code for function main:
0x0000000000400506 <+0>:push rbp
0x0000000000400507 <+1>:mov rbp,rsp:
0x000000000040050a <+4>:mov DWORD PTR [rbp-0x4],edi
0x000000000040050d <+7>:mov QWORD PTR [rbp-0x10],rsi
0x0000000000400511 <+11>:mov eax,0x0
0x0000000000400516 <+16>:pop rbp
0x0000000000400517 <+17>:ret
End of assembler dump.
(gdb)
# or off
$ bh_intel off
$ gdb ./input
(gdb) disass main
Dump of assembler code for function main:
Dump of assembler code for function main:
0x0000000000400506 <+0>: push %rbp
0x0000000000400507 <+1>: mov %rsp,%rbp
0x000000000040050a <+4>: mov %edi,-0x4(%rbp)
0x000000000040050d <+7>: mov %rsi,-0x10(%rbp)
0x0000000000400511 <+11>: mov $0x0,%eax
0x0000000000400516 <+16>: pop %rbp
0x0000000000400517 <+17>: retq
End of assembler dump.
(gdb)
# hexdump -C MB_DEV
.....
00005860 41 4d 00 42 00 2d 00 66 00 69 00 0f 00 a1 6c 00 |AM.B.-.f.i....l.|
00005870 65 00 2e 00 74 00 78 00 74 00 00 00 00 00 ff ff |e...t.x.t.......|
00005880 4d 42 2d 46 49 4c 45 20 54 58 54 20 00 41 26 be |MB-FILE TXT .A&.|
00005890 69 54 69 54 00 00 26 be 69 54 05 00 1b 00 00 00 |iTiT..&.iT......|
.....
# bh_zerostring MB_DEV MB-FILE
7+0 records in
7+0 records out
7 bytes copied, 7.3484e-05 s, 95.3 kB/s
# hexdump -C MB_DEV
.....
00005860 41 4d 00 42 00 2d 00 66 00 69 00 0f 00 a1 6c 00 |AM.B.-.f.i....l.|
00005870 65 00 2e 00 74 00 78 00 74 00 00 00 00 00 ff ff |e...t.x.t.......|
00005880 00 00 00 00 00 00 00 20 54 58 54 20 00 41 26 be |....... TXT .A&.|
00005890 69 54 69 54 00 00 26 be 69 54 05 00 1b 00 00 00 |iTiT..&.iT......|
.....
# mount -o loop -t vfat MB_DEV /mnt/
# ls -la /mnt/
total 16
drwxr-xr-x 2 root root 16384 Dec 31 1969 .
drwxr-xr-x 1 root root 152 Feb 17 15:21 ..
31 changes: 25 additions & 6 deletions doc/source/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,37 @@ Accepts as input all output formats str2hex function.
rock
bh_str2dec
----------
Convert one or more bytes to their decimal equivalent.
.. note::
``bh_str2dec`` [char or string]
.. code-block:: bash
$ bh_str2dec A
65
$ bh_str2dec mbin
109 98 105 110
$ bh_str2dec root
114 111 111 116
bh_str2hexr
-----------
Converts string in hex byte equivalent to each char (hex string). reverse mode
.. note::
``bh_str2hexr`` [-x] [-0x] [-c] [-s] [string]
``bh_str2hexr`` [-x] [-0x] [-c] [string]
.. code-block:: bash
Expand All @@ -115,8 +138,6 @@ Converts string in hex byte equivalent to each char (hex string). reverse mode
\x6f\x64\x6e\x61\x6e\x72\x65\x46
$ bh_str2hexr -0x 'Fernado'
0x6f 0x64 0x6e 0x61 0x6e 0x72 0x65 0x46
$ bh_str2hexr -s 'Fernando'
0x6f646e616e726546
bh_str2hex
Expand All @@ -126,7 +147,7 @@ Converts string in hex byte equivalent to each char (hex string).
.. note::
``bh_str2hex`` [-x] [-0x] [-c] [-s] [string]
``bh_str2hex`` [-x] [-0x] [-c] [string]
.. code-block:: bash
Expand All @@ -136,8 +157,6 @@ Converts string in hex byte equivalent to each char (hex string).
\x46\x65\x72\x6e\x61\x6e\x64\x6f
$ bh_str2hex -0x 'Fernado'
0x46 0x65 0x72 0x6e 0x61 0x6e 0x64 0x6f
$ bh_str2hex -s 'Fernando'
0x4665726e616e646f
bh_urldecode
Expand Down
2 changes: 1 addition & 1 deletion src/strings/bh_str2hex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ bh_str2hex() {
echo
;;
esac
}
}

0 comments on commit 9d6b77b

Please sign in to comment.