-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathupload-unix.sh
More file actions
281 lines (244 loc) · 8.67 KB
/
upload-unix.sh
File metadata and controls
281 lines (244 loc) · 8.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/usr/bin/env bash
# Credits: REDD
# TARGET OS: Unix - BASH/Shell Script
# Version: 2.1 - Unified UNIX/Linux Version
# SET YOUR EMAIL BELOW OR SET IT IN THE SCRIPT!
EMAIL=""
# CONFIGURATION OPTIONS
RECURSIVE_MODE=false # Set to true to scan subdirectories
VERIFY_PCAP=false # Set to false to skip PCAP file verification (original behavior)
SHOW_PROGRESS=true # Set to true to show curl progress meter
CURR_DIR="$PWD"
SENT_DIR="$CURR_DIR/sent"
LOG_FILE="$CURR_DIR/upload_history.log"
# Check for dependencies
check_dependencies() {
local missing_deps=()
# Check for curl - required
if ! command -v curl &> /dev/null; then
missing_deps+=("curl")
fi
# Check for file - useful for PCAP verification but not required
if ! command -v file &> /dev/null; then
if [ "$VERIFY_PCAP" = true ]; then
echo "Note: 'file' command not found. Basic PCAP verification will be used."
fi
fi
# Check for readlink or realpath - at least one is needed for path resolution
if ! command -v readlink &> /dev/null && ! command -v realpath &> /dev/null; then
echo "Warning: Neither 'readlink' nor 'realpath' found. Basic path resolution will be used."
fi
# If curl is missing, we need to report it
if [ ${#missing_deps[@]} -gt 0 ]; then
echo "Error: Required dependencies missing: ${missing_deps[*]}"
echo "Please install the missing dependencies and try again."
echo "On Debian/Ubuntu: sudo apt-get install ${missing_deps[*]}"
echo "On Fedora/RHEL: sudo dnf install ${missing_deps[*]}"
echo "On Arch Linux: sudo pacman -S ${missing_deps[*]}"
exit 1
fi
}
# Run dependency check
check_dependencies
if [ -f "email.txt" ]; then
if [ "$EMAIL" == "" ]; then
EMAIL_FROM_FILE=$(cat email.txt)
EMAIL="$EMAIL_FROM_FILE"
fi
fi
clear;
# Check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check if file is a valid PCAP
is_valid_pcap() {
local file="$1"
if command_exists file; then
# Check with file command if available
file -b "$file" | grep -qi "pcap\|libpcap\|tcpdump\|capture" && return 0
else
# Simple header check if file command not available
# Check for pcap magic numbers: d4c3b2a1 or a1b2c3d4
# PCAPNG: 0a0d0d0a
local magic=$(hexdump -n 4 -e '1/4 "%08x"' "$file" 2>/dev/null)
if [[ "$magic" == "d4c3b2a1" || "$magic" == "a1b2c3d4" || "$magic" == "0a0d0d0a" ]]; then
return 0
fi
fi
return 1
}
function PAUSE(){
echo ""
echo "DONE!!"
read -p "Press any key to continue . . ."
echo ""
}
function SET_EMAIL(){
read -p "Enter the Email you want to use for Results: " EMAIL
echo "$EMAIL" > email.txt
CHECK_EMAIL;
}
# Find all PCAP files
function FIND_PCAPS() {
local pcap_files=()
if [ "$RECURSIVE_MODE" = true ]; then
# Find PCAP files recursively
echo "Searching for PCAP files in $CURR_DIR and subdirectories..."
if command_exists find; then
while IFS= read -r file; do
pcap_files+=("$file")
done < <(find "$CURR_DIR" -type f -name "*.pcap" 2>/dev/null)
else
# Fallback if find is not available
pcap_files=($(ls -R 2>/dev/null | grep -i "\.pcap$"))
fi
else
# Find PCAP files in current directory only
for file in *.pcap; do
# Skip if no matches found
[[ -e "$file" ]] || continue
pcap_files+=("$file")
done
fi
echo "${pcap_files[@]}"
}
function SEND(){
local curl_opts=""
# Check if any .pcap files exist before iterating
local pcap_files=($(FIND_PCAPS))
if [ ${#pcap_files[@]} -gt 0 ]; then
# Set curl options for progress display
if [ "$SHOW_PROGRESS" = true ]; then
curl_opts="-#"
else
curl_opts="-s"
fi
echo "Found ${#pcap_files[@]} PCAP files to process."
for i in "${pcap_files[@]}"; do
echo "Processing: $i"
# Verify PCAP file if option enabled
if [ "$VERIFY_PCAP" = true ]; then
if ! is_valid_pcap "$i"; then
echo "Warning: $i does not appear to be a valid PCAP file. Skipping."
continue
fi
fi
# Use readlink -m for Linux, fall back to other methods if needed
UPLOAD_FILE_PATH=$(readlink -m "$i" 2>/dev/null || readlink -f "$i" 2>/dev/null || realpath "$i" 2>/dev/null || echo "$PWD/$i")
echo "Uploading: $i"
# Execute the curl command with progress options
curl $curl_opts -X POST -F "email=$EMAIL" -F "file=@$UPLOAD_FILE_PATH" https://api.onlinehashcrack.com
# Create sent directory if it doesn't exist
if [ ! -d "$SENT_DIR" ]; then
mkdir -p "$SENT_DIR"
fi
# Create subdirectories in sent directory if recursive mode
if [ "$RECURSIVE_MODE" = true ] && [[ "$i" == */* ]]; then
rel_dir=$(dirname "$i")
mkdir -p "$SENT_DIR/$rel_dir"
mv "$i" "$SENT_DIR/$i"
else
mv "$i" "$SENT_DIR/$(basename "$i")"
fi
# Log the upload
echo "$(date '+%Y-%m-%d %H:%M:%S') - Uploaded: $i - Email: $EMAIL" >> "$LOG_FILE"
echo "Done processing: $i"
echo "---------------------------------"
done
echo "All PCAP files have been processed."
else
echo "NO PCAP FILES FOUND!"
echo ""
fi
}
function CHECK_PCAPS(){
SEND;
}
function CHECK_EMAIL(){
# More compatible email validation
if [[ "$EMAIL" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
CHECK_PCAPS;
else
echo "$EMAIL is NOT a Valid Email! Please try another Email."
SET_EMAIL;
fi
}
function SHOW_HELP() {
echo "Usage: $0 [OPTIONS]"
echo
echo "Options:"
echo " -h, --help Show this help message"
echo " -r, --recursive Search for PCAP files in subdirectories"
echo " -v, --verify Verify files are valid PCAP files before upload"
echo " -n, --no-verify Skip PCAP file verification (default behavior)"
echo " -s, --silent Hide progress indicators"
echo " -e EMAIL Specify email address for results"
echo
echo "Example: $0 -r -e your@email.com"
}
# Parse command line arguments
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-r|--recursive)
RECURSIVE_MODE=true
shift
;;
-v|--verify)
VERIFY_PCAP=true
shift
;;
-n|--no-verify)
VERIFY_PCAP=false
shift
;;
-s|--silent)
SHOW_PROGRESS=false
shift
;;
-e)
EMAIL="$2"
shift
shift
;;
-h|--help)
SHOW_HELP
exit 0
;;
*) # unknown option
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
function HEADER(){
echo ""
echo ""
echo " ::::::::: :::::::::: ::::::::: ::::::::: ::: :::::::: "
echo " :+: :+: :+: :+: :+: :+: :+: :+ :+: :+: "
echo " +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ "
echo " +#++:++#: +#++:++# +#+ +:+ +#+ +:+ +#++:++#++ "
echo " +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ "
echo " #+# #+# #+# #+# #+# #+# #+# #+# #+# "
echo " ### ### ########## ######### ######### ######## "
echo " REDD's PCAP OHC UPLOADER"
echo " ( Version 2.1 - UNIX )"
echo ""
if [ "$RECURSIVE_MODE" = true ]; then echo "RECURSIVE MODE: ENABLED"; fi
if [ "$VERIFY_PCAP" = true ]; then echo "PCAP VERIFICATION: ENABLED"; fi
echo ""
echo ""
echo "Email: $EMAIL";
echo ""
CHECK_EMAIL;
}
# If help was requested, show it. Otherwise, run the main program
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
SHOW_HELP
else
HEADER;
PAUSE;
fi