Jak przeglądać pliki binarne z bash?
Chciałbym wyświetlić zawartość pliku w bieżącym katalogu, ale w formacie binarnym z linii poleceń. Jak mogę to osiągnąć?
12 answers
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-04-10 08:47:10
hexdump -C yourfile.bin
Chyba, że chcesz to oczywiście edytować. Większość dystrybucji Linuksa ma domyślnie hexdump
(ale oczywiście nie wszystkie).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-06-02 00:29:47
vi your_filename
Hit esc
Wpisz :%!xxd
Aby wyświetlić ciągi szesnastkowe, n :%!xxd -r
aby powrócić do normalnej edycji.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-12-06 11:45:56
Jako alternatywa zawsze jest od -xc filename
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-11-19 18:07:16
sudo apt-get install bless
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-03 09:06:03
Jeśli chcesz otworzyć pliki binarne (w CentOS 7):
strings <binary_filename>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-10-03 06:57:33
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-11-19 18:08:36
$ echo -n 'Hello world!' | hd
00000000 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 |Hello world!|
0000000c
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-07-30 15:40:47
Możesz otworzyć emacs (w trybie terminalowym, używając na przykład emacs -nw
), a następnie użyć trybu Hexl: M-x hexl-mode
.
Https://www.gnu.org/software/emacs/manual/html_node/emacs/Editing-Binary-Files.html
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-04-11 15:11:15
Aby przekonwertować plik na jego kody binarne (reprezentacja szesnastkowa) mówimy:
xxd filename #
Np:
xxd hello.c #
Aby zobaczyć całą zawartość i kody w pliku binarnym, możemy użyć komend takich jak readelf
i objdump
, hexdump
,... .
Na przykład, jeśli chcemy zobaczyć wszystkie konwertowanie całej zawartości pliku binarnego (wykonywalne, biblioteki współdzielone, pliki obiektowe) mówimy:
hexdump binaryfilename
Np.
hexdump /bin/bash
Ale readelf jest najlepszym narzędziem do analizy elf(wykonywalnego i linkującego format) plików. więc jeśli powiemy:
readelf -a /bin/bash
Cała zawartość w pliku binarnym bash będzie nam pokazana, również możemy dostarczyć różne flagi dla readelf, aby zobaczyć wszystkie sekcje i nagłówki pliku elf osobno, na przykład, jeśli chcemy zobaczyć tylko nagłówek elf mówimy:
readelf -h /bin/bash
Do odczytu wszystkich segmentów pliku:
readelf -l /bin/bash
Do odczytu wszystkich sekcji pliku:
readelf -S /bin/sh
Ale znowu jako podsumowanie, do czytania normalnego pliku typu " hello.c " i binarny plik jak bash w path / bin / bash w Linuksie mówimy:
xxd hello.c
readelf -a /bin/bash
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-09-09 01:55:31
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-10-21 08:39:42
Możesz użyć pliku binarnego hexdump
sudo apt-get install hexdump
hexdump -C yourfile.bin
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-05-24 16:49:27