Skip to content

Commit

Permalink
fix the read me, remove the scan script and change it into example ou…
Browse files Browse the repository at this point in the history
…t put
  • Loading branch information
DyanGalih committed Dec 22, 2023
1 parent cdd8712 commit dfd7eab
Showing 1 changed file with 5 additions and 49 deletions.
54 changes: 5 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,15 @@ This bash script reads a list of search strings from a file, searches for these
To use this script, you need to call it with the path to the directory you want to search as an argument. For example:

```bash
sh scan.sh /var/www/html
bash scan.sh /var/www/html
```

In this example, the script will search for the strings in the `/var/www/html` directory and its subdirectories.

## Script

Here is the script:

```bash
#!/bin/bash

# Check if an argument was provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 path"
exit 1
fi

# Store the argument into a variable
path=$1

# Read the file list.txt and store each line into the array search_strings
readarray -t search_strings < list.txt

# Get the total number of search strings
total=${#search_strings[@]}

# Create an empty array to store the grep results
grep_results=()

# Initialize a counter
counter=0

# Loop through each search string in the array
for string in "${search_strings[@]}"; do
# Increment the counter
((counter++))

# Print the current position and total
echo "Scanning string $counter of $total: $string"

# Run the grep command with the current search string and store the results in the array grep_results
while IFS= read -r line; do
grep_results+=("$line")
done < <(grep -Rlw "$path" -e "$string")
done

# Remove duplicates from the array grep_results
readarray -t unique_grep_results < <(printf '%s\n' "${grep_results[@]}" | sort -u)

# Display the unique results
printf '%s\n' "${unique_grep_results[@]}"

## Example Output
```
The file /var/www/backdoor.php is a backdoor.
The file /var/www/new_backdoor.php is not a backdoor, please inform this script author for the next investigation.
```

## Input File
Expand Down

0 comments on commit dfd7eab

Please sign in to comment.