diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ff27c2b..83c50111 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,13 +16,16 @@ jobs: sudo apt-get --assume-yes update sudo apt-get --assume-yes install pandoc texlive-xetex texinfo go install github.com/n0x1m/md2gmi@latest + - name: Linting + run: sh lint.sh - name: Build ebooks - run: make pdf epub info gmi + run: make pdf epub info gmi one - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: r2book path: | + r2book.md r2book.pdf r2book.epub r2book.info.gz @@ -77,6 +80,7 @@ jobs: generate_release_notes: true files: | r2book.pdf + r2book.md r2book.epub r2book.info.gz r2book-gmi.tar.gz diff --git a/Makefile b/Makefile index 99fb51cc..af6442d7 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,9 @@ epub: texi: pandoc $(CHAPTERS) $(PANDOC_OPTIONS) -o r2book.texi +one r2book.md: + sh one.sh > r2book.md + info: texi rm -f r2book.info r2book.info.gz makeinfo --force --no-split r2book.texi diff --git a/lint.sh b/lint.sh new file mode 100644 index 00000000..154d3555 --- /dev/null +++ b/lint.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +posix_pushd() { + if [ $# -eq 0 ]; then + echo "Usage: pushd " + return 1 + fi + + DIR=$1 + if [ ! -d "${DIR}" ]; then + echo "pushd: ${DIR}: No such directory" + return 1 + fi + + # Save the current directory on the stack + DIR_STACK="$PWD $DIR_STACK" + + # Change to the new directory + cd "${DIR}" || return 1 + + # Print the new stack + echo "$DIR_STACK" +} + +# Function to pop a directory off the stack +posix_popd() { + if [ -z "$DIR_STACK" ]; then + echo "popd: directory stack empty" + return 1 + fi + + # Extract the first directory from the stack + DIR=$(echo "$DIR_STACK" | awk '{print $1}') + DIR_STACK=$(echo "$DIR_STACK" | cut -d' ' -f2-) + + # Change to the directory + cd "$DIR" || return 1 + + # Print the new stack + echo "$DIR_STACK" +} + +RV=0 +find_markdown_files() { + (echo "$1" | grep "://") && return + local D=`dirname "$1"` + posix_pushd "$D" > /dev/null + local F=`basename "$1"` + local file="$F" + + echo "$PWD/$F" + # Extract referenced markdown files + grep -o '\[.*\](.*\.md)' "$file" | sed -n 's/.*(\(.*\.md\)).*/\1/p' | grep -v :// | while read -r ref; do + if [ -f "$ref" ]; then + find_markdown_files "$ref" + else + echo "\033[31mReferenced file '$ref' not found. From $PWD/$F\033[0m" > /dev/stderr + RV=1 + fi + done + posix_popd > /dev/null +} + +# Check if a file is provided +F="$1" +[ -z "$1" ] && F=src/SUMMARY.md + +# Start the recursive search with the provided file +find_markdown_files "$F" +exit $RV diff --git a/one.sh b/one.sh new file mode 100644 index 00000000..b5766f1b --- /dev/null +++ b/one.sh @@ -0,0 +1,2 @@ +#!/bin/sh +cat `sh lint.sh` diff --git a/src/analysis/syscalls.md b/src/analysis/syscalls.md index acfdfcba..b499ef05 100644 --- a/src/analysis/syscalls.md +++ b/src/analysis/syscalls.md @@ -38,9 +38,9 @@ the addresses where particular syscalls were found and list them. ... ``` -To reduce searching time it is possible to [restrict the searching](../search_bytes/configurating_the_search.md) range for only executable segments or sections with `/as @e:search.in=io.maps.x` +To reduce searching time it is possible to [restrict the searching](../search/configurating_the_search.md) range for only executable segments or sections with `/as @e:search.in=io.maps.x` -Using the [ESIL emulation](emulation.md) radare2 can print syscall arguments in the disassembly output. To enable the linear (but very rough) emulation use `asm.emu` configuration variable: +Using the [ESIL emulation](../emulation/intro.md) radare2 can print syscall arguments in the disassembly output. To enable the linear (but very rough) emulation use `asm.emu` configuration variable: ``` [0x0001ece0]> e asm.emu=true [0x0001ece0]> s 0x000187c2 diff --git a/src/analysis/types.md b/src/analysis/types.md index e9e8dd4b..4b2540c1 100644 --- a/src/analysis/types.md +++ b/src/analysis/types.md @@ -107,7 +107,7 @@ dir.types: Default path to look for cparse type files Notice below we have used `ts` command, which basically converts the C type description (or to be precise it's SDB representation) -into the sequence of `pf` commands. See more about [print format](../basic_commands/print_modes.md). +into the sequence of `pf` commands. See more about [print format](../commandline/print_modes.md). The `tp` command uses the `pf` string to print all the members of type at the current offset/given address: diff --git a/src/commandline/block_size.md b/src/commandline/block_size.md index 0c8c97f2..a352eb4c 100644 --- a/src/commandline/block_size.md +++ b/src/commandline/block_size.md @@ -50,4 +50,4 @@ Another way around is to use special variables `$FB` and `$FS` which denote Func \ 0x00001f97 c3 ret ``` -Note: don't put space after `!` size designator. See also [Command Format](../first_steps/command_format.md). +Note: don't put space after `!` size designator. See also [Command Format](../first_steps/syntax.md). diff --git a/src/commandline/intro.md b/src/commandline/intro.md index 4698041c..33dd9642 100644 --- a/src/commandline/intro.md +++ b/src/commandline/intro.md @@ -2,7 +2,7 @@ Most command names in radare are derived from action names. They should be easy to remember, as they are short. Actually, all commands are single letters. Subcommands or related commands are specified using the second character of the command name. For example, `/ foo` is a command to search plain string, while `/x 90 90` is used to look for hexadecimal pairs. -The general format for a valid command (as explained in the [Command Format](../first_steps/command_format.md) chapter) looks like this: +The general format for a valid command (as explained in the [Command Format](../first_steps/syntax.md) chapter) looks like this: ``` [.][times][cmd][~grep][@[@iter]addr!size][|>pipe] ; ... diff --git a/src/commandline/print_modes.md b/src/commandline/print_modes.md index aa99d92d..e9bc7c8a 100644 --- a/src/commandline/print_modes.md +++ b/src/commandline/print_modes.md @@ -64,7 +64,7 @@ Tip: when using json output, you can append the `~{}` to the command to get a pr ] ``` -For more on the magical powers of `~` see the help in `?@?`, and the [Command Format](../first_steps/command_format.md) chapter earlier in the book. +For more on the magical powers of `~` see the help in `?@?`, and the [Command Format](../first_steps/syntax.md) chapter earlier in the book. ### Hexadecimal View @@ -435,4 +435,4 @@ e asm.syntax = att ``` You can also check `asm.pseudo`, which is an experimental pseudocode view, -and `asm.esil` which outputs [ESIL](../disassembling/esil.md) ('Evaluable Strings Intermediate Language'). ESIL's goal is to have a human-readable representation of every opcode semantics. Such representations can be evaluated (interpreted) to emulate effects of individual instructions. +and `asm.esil` which outputs [ESIL](../emulation/esil.md) ('Evaluable Strings Intermediate Language'). ESIL's goal is to have a human-readable representation of every opcode semantics. Such representations can be evaluated (interpreted) to emulate effects of individual instructions. diff --git a/src/emulation/intro.md b/src/emulation/intro.md index f82c482e..79f50509 100644 --- a/src/emulation/intro.md +++ b/src/emulation/intro.md @@ -7,7 +7,7 @@ Understanding the distinction between static analysis and dynamic analysis is cr Radare2 employs its own intermediate language and virtual machine, known as ESIL, for partial emulation (or imprecise full emulation). -Radare2's [ESIL](../disassembling/esil.md) supports partial emulation across all platforms by evaluating those expressions. +Radare2's [ESIL](../emulation/esil.md) supports partial emulation across all platforms by evaluating those expressions. ## Use Cases diff --git a/src/plugins/intro.md b/src/plugins/intro.md index f01def3c..75bf5377 100644 --- a/src/plugins/intro.md +++ b/src/plugins/intro.md @@ -10,7 +10,7 @@ This section aims to explain what are the plugins, how to write them and use the All of them can be installed via r2pm. -* [r2frida](r2frida.md) - Frida and radare2 better together +* [r2frida](../r2frida/intro.md) - Frida and radare2 better together * r2ghidra - use the Ghidra decompiler from radare2 * r2dec - a decompiler written in JS for r2 * r2yara - loading, scanning and creating Yara rules diff --git a/src/refcard/intro.md b/src/refcard/intro.md index adcc4615..72d70085 100644 --- a/src/refcard/intro.md +++ b/src/refcard/intro.md @@ -118,7 +118,7 @@ have to press keys to get the actions happen instead of commands. | n/N | Seek next/prev function/flag/hit (scr.nkey) | | C | Toggle (C)olors | | R | Randomize color palette (ecr) | -| tT | Tab related. see also [tab](visual_panels.md) | +| tT | Tab related. see also [tab](../visual/visual_panels.md) | | v | Visual code analysis menu | | V | (V)iew graph (agv?) | | wW | Seek cursor to next/prev word | diff --git a/src/signatures/zignatures.md b/src/signatures/zignatures.md index 0c40666c..23e08141 100644 --- a/src/signatures/zignatures.md +++ b/src/signatures/zignatures.md @@ -95,7 +95,7 @@ There is an important moment though, if we just run it "as is" - it wont find an hits: 0 [0x000051c0]> ``` -Note the searching address - this is because we need to [adjust the searching](../search_bytes/configurating_the_search.md) range first: +Note the searching address - this is because we need to [adjust the searching](../search/configurating_the_search.md) range first: ``` [0x000051c0]> e search.in=io.section [0x000051c0]> z/