Skip to content

Commit

Permalink
Add hashcat command functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ente0 committed May 24, 2024
1 parent 3c8becc commit 21bb8ca
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 157 deletions.
54 changes: 33 additions & 21 deletions crack-bruteforce.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
#!/bin/bash

# Brute-force
# Example: hashcat -a 3 -m 0 example.hash ?a?a?a?a?a?a

# Function to handle hashcat execution and check for success
run_hashcat() {
local session="$1"
local hashmode="$2"
local mask="$3"
local workload="$4"
local status_timer="$5"

if [ "$status_timer" = "y" ]; then
hashcat_output=$(hashcat --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask")
else
hashcat_output=$(hashcat --session="$session" -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask")
fi

if echo "$hashcat_output" | grep -q "Cracked"; then
echo -e "${GREEN}Hashcat found the plaintext! Saving logs...${NC}"
sleep 2
save_logs
save_settings "$session" "" "" "$mask"
else
echo -e "${RED}Hashcat did not find the plaintext.${NC}"
sleep 2
fi
}


source windows/functions.sh
#define_default_parameters
Expand Down Expand Up @@ -36,13 +60,13 @@ read status_timer_input

# Prompt for min length
echo -e "${MAGENTA}Enter Minimum Length (press Enter to use default '$default_min_length'):${NC}"
read min_length
min_length=${min_length:-$default_min_length}
read min_length_input
min_length=${min_length_input:-$default_min_length}

# Prompt for max length
echo -e "${MAGENTA}Enter Maximum Length (press Enter to use default '$default_max_length'):${NC}"
read max_length
max_length=${max_length:-$default_max_length}
read max_length_input
max_length=${max_length_input:-$default_max_length}

# Prompt hash attack mode
echo -e "${MAGENTA}Enter hash attack mode (press Enter to use default '22000'):${NC}"
Expand All @@ -54,21 +78,9 @@ echo -e "${MAGENTA}Enter workload (press Enter to use default '$default_workload
read workload_input
workload=${workload_input:-$default_workload}

echo -e "${MAGENTA}Use status timer? (press Enter to use default '$default_status_timer') [y/n]:${NC}"
read status_timer_input
status_timer=${status_timer_input:-default_status_timer}

# Print the hashcat command
echo -e "${GREEN}Restore >>${NC} $default_restorepath/$session"
echo -e "${GREEN}Command >>${NC} hashcat --session="$session" --increment --increment-min="$min_length" --increment-max="$max_length" -m "$hashmode" hash.txt -a 6 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" "$mask""

# Execute hashcat with combined attack (wordlist + mask) and increment options
if [ "$status_timer" = "y" ]; then
hashcat --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask"
else
hashcat --session="$session" -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask"
fi

# Save successful settings
save_settings "$session" "" "" "$mask" ""
save_logs
echo -e "${GREEN}Command >>${NC} hashcat --session=\"$session\" --increment --increment-min=\"$min_length\" --increment-max=\"$max_length\" -m \"$hashmode\" hash.txt -a 3 -w \"$workload\" --outfile-format=2 -o plaintext.txt \"$mask\""

# Execute hashcat with brute-force attack and increment options
run_hashcat "$session" "$hashmode" "$mask" "$workload" "$status_timer"
54 changes: 34 additions & 20 deletions crack-combo.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
#!/bin/bash

# Hybrid Wordlist + Mask
# Example: hashcat -a 6 -m 0 example.hash example.dict ?a?a?a?a?a?a
# Example: hashcat -a 6 -m 0 example.hash example.dict ?a?a?a?a?a?a

# Function to handle hashcat execution and check for success
run_hashcat() {
local session="$1"
local hashmode="$2"
local wordlist_path="$3"
local wordlist="$4"
local mask="$5"
local workload="$6"
local status_timer="$7"
local min_length="$8"
local max_length="$9"

if [ "$status_timer" = "y" ]; then
hashcat_output=$(hashcat --session="$session" --status --status-timer=2 --increment --increment-min="$min_length" --increment-max="$max_length" -m "$hashmode" hash.txt -a 6 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" "$mask")
else
hashcat_output=$(hashcat --session="$session" --increment --increment-min="$min_length" --increment-max="$max_length" -m "$hashmode" hash.txt -a 6 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" "$mask")
fi

if echo "$hashcat_output" | grep -q "Cracked"; then
echo -e "${GREEN}Hashcat found the plaintext! Saving logs...${NC}"
sleep 2
save_logs
save_settings "$session" "$wordlist_path" "$wordlist" "$mask"
else
echo -e "${RED}Hashcat did not find the plaintext.${NC}"
sleep 2
fi
}


source windows/functions.sh
Expand Down Expand Up @@ -33,7 +61,7 @@ wordlist=${wordlist_input:-$default_wordlist}

echo -e "${RED}Enter Masks Path (press Enter to use default '$default_masks'):${NC}"
read mask_path_input
masks_path=${rules_path_input:-$default_rules}
masks_path=${mask_path_input:-$default_masks}

echo -e "${MAGENTA}Available Masks in $masks_path:${NC}"
ls "$masks_path"
Expand All @@ -54,7 +82,7 @@ max_length=${max_length_input:-$default_max_length}

echo -e "${MAGENTA}Use status timer? (press Enter to use default '$default_status_timer') [y/n]:${NC}"
read status_timer_input
status_timer=${status_timer_input:-default_status_timer}
status_timer=${status_timer_input:-$default_status_timer}

# Prompt hash attack mode
echo -e "${MAGENTA}Enter hash attack mode (press Enter to use default '22000'):${NC}"
Expand All @@ -66,23 +94,9 @@ echo -e "${MAGENTA}Enter workload (press Enter to use default '$default_workload
read workload_input
workload=${workload_input:-$default_workload}

echo -e "${MAGENTA}Use status timer? (press Enter to use default '$default_status_timer') [y/n]:${NC}"
read status_timer_input
status_timer=${status_timer_input:-default_status_timer}

# Print the hashcat command
echo -e "${GREEN}Restore >>${NC} $default_restorepath/$session"
echo -e "${GREEN}Command >>${NC} hashcat --session="$session" --increment --increment-min="$min_length" --increment-max="$max_length" -m "$hashmode" hash.txt -a 6 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" "$mask""
echo -e "${GREEN}Command >>${NC} hashcat --session=\"$session\" --increment --increment-min=\"$min_length\" --increment-max=\"$max_length\" -m \"$hashmode\" hash.txt -a 6 -w \"$workload\" --outfile-format=2 -o plaintext.txt \"$wordlist_path/$wordlist\" \"$mask\""

# Execute hashcat with combined attack (wordlist + mask) and increment options
if [ "$status_timer" = "y" ]; then
hashcat --session="$session" --status --status-timer=2 --increment --increment-min="$min_length" --increment-max="$max_length" -m "$hashmode" hash.txt -a 6 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" "$mask"
else
hashcat --session="$session" --increment --increment-min="$min_length" --increment-max="$max_length" -m 22000 hash.txt -a 6 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" "$mask"
fi

# Save successful settings
save_settings "$session" "$wordlist_path" "$wordlist" "$mask" ""
save_logs


run_hashcat "$session" "$hashmode" "$wordlist_path" "$wordlist" "$mask" "$workload" "$status_timer" "$min_length" "$max_length"
50 changes: 34 additions & 16 deletions crack-rule.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
#!/bin/bash

# Wordlist + Rule
# Example: hashcat -a 0 -m 0 example.hash example.dict example.rule
# Example: hashcat -a 0 -m 0 example.hash example.dict example.rule

# Function to handle hashcat execution and check for success
run_hashcat() {
local session="$1"
local hashmode="$2"
local wordlist_path="$3"
local wordlist="$4"
local rule_path="$5"
local rule="$6"
local workload="$7"
local status_timer="$8"

if [ "$status_timer" = "y" ]; then
hashcat_output=$(hashcat --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" -r "$rule_path/$rule")
else
hashcat_output=$(hashcat --session="$session" -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" -r "$rule_path/$rule")
fi

if echo "$hashcat_output" | grep -q "Cracked"; then
echo -e "${GREEN}Hashcat found the plaintext! Saving logs...${NC}"
sleep 2
save_logs
save_settings "$session" "$wordlist_path" "$wordlist" "$rule"
else
echo -e "${RED}Hashcat did not find the plaintext.${NC}"
sleep 2
fi
}


source windows/functions.sh
Expand Down Expand Up @@ -33,9 +60,9 @@ wordlist=${wordlist_input:-$default_wordlist}

echo -e "${RED}Enter Rules Path (press Enter to use default '$default_rules'):${NC}"
read rule_path_input
rule_path=${rules_path_input:-$default_rules}
rule_path=${rule_path_input:-$default_rules}

echo -e "${MAGENTA}Available Rules in $rules_path:${NC}"
echo -e "${MAGENTA}Available Rules in $rule_path:${NC}"
ls "$rule_path"

echo -e "${MAGENTA}Enter Rule (press Enter to use default '$default_rule'):${NC}"
Expand All @@ -54,20 +81,11 @@ workload=${workload_input:-$default_workload}

echo -e "${MAGENTA}Use status timer? (press Enter to use default '$default_status_timer') [y/n]:${NC}"
read status_timer_input
status_timer=${status_timer_input:-default_status_timer}
status_timer=${status_timer_input:-$default_status_timer}

# Print the hashcat command
echo -e "${GREEN}Restore >>${NC} $default_restorepath/$session"
echo -e "${GREEN}Command >>${NC} hashcat --session="$session" -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist" -r "$rule""
echo -e "${GREEN}Command >>${NC} hashcat --session=\"$session\" -m \"$hashmode\" hash.txt -a 0 -w \"$workload\" --outfile-format=2 -o plaintext.txt \"$wordlist_path/$wordlist\" -r \"$rule_path/$rule\""

# Execute hashcat with rules
if [ "$status_timer" = "y" ]; then
hashcat --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" -r "$rule"
else
hashcat --session="$session" -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" -r "$rule"
fi

# Save successful settings
save_settings "$session" "$wordlist_path" "$wordlist" "" "$rule"
save_logs

run_hashcat "$session" "$hashmode" "$wordlist_path" "$wordlist" "$rule_path" "$rule" "$workload" "$status_timer"
44 changes: 29 additions & 15 deletions crack-wordlist.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
#!/bin/bash

# Wordlist
# Example: hashcat -a 0 -m 0 example.hash example.dict
# Example: hashcat -a 0 -m 0 example.hash example.dict

# Function to handle hashcat execution and check for success
run_hashcat() {
local session="$1"
local hashmode="$2"
local wordlist_path="$3"
local wordlist="$4"
local workload="$5"
local status_timer="$6"

if [ "$status_timer" = "y" ]; then
hashcat_output=$(hashcat --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist")
else
hashcat_output=$(hashcat --session="$session" -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist")
fi

if echo "$hashcat_output" | grep -q "Cracked"; then
echo -e "${GREEN}Hashcat found the plaintext! Saving logs...${NC}"
save_logs
save_settings "$session" "$wordlist_path" "$wordlist" ""
else
echo -e "${RED}Hashcat did not find the plaintext.${NC}"
fi
}


source windows/functions.sh
Expand All @@ -24,7 +47,7 @@ echo -e "${RED}Enter Wordlists Path (press Enter to use default '$default_wordli
read wordlist_path_input
wordlist_path=${wordlist_path_input:-$default_wordlists}

echo -e "${MAGENTA}Available Wordlists in $wordlist_path:${NC} "
echo -e "${MAGENTA}Available Wordlists in $wordlist_path:${NC}"
ls "$wordlist_path"

echo -e "${MAGENTA}Enter Wordlist (press Enter to use default '$default_wordlist'):${NC}"
Expand All @@ -43,20 +66,11 @@ workload=${workload_input:-$default_workload}

echo -e "${MAGENTA}Use status timer? (press Enter to use default '$default_status_timer') [y/n]:${NC}"
read status_timer_input
status_timer=${status_timer_input:-default_status_timer}
status_timer=${status_timer_input:-$default_status_timer}

# Print the hashcat command
echo -e "${GREEN}Restore >>${NC} $default_restorepath/$session"
echo -e "${GREEN}Command >>${NC} hashcat --session="$session" -m "$hashmode" hash.txt -a 0 -w $wordload --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist""
echo -e "${GREEN}Command >>${NC} hashcat --session=\"$session\" -m \"$hashmode\" hash.txt -a 0 -w $workload --outfile-format=2 -o plaintext.txt \"$wordlist_path/$wordlist\""

# Execute hashcat with the specified wordlist
if [ "$status_timer" = "y" ]; then
hashcat --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist"
else
hashcat --session="$session" -m "$hashmode" hash.txt -a 0 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist"
fi
# Save successful settings
save_settings "$session" "$wordlist_path" "$wordlist" ""
save_logs


run_hashcat "$session" "$hashmode" "$wordlist_path" "$wordlist" "$workload" "$status_timer"
37 changes: 28 additions & 9 deletions windows/crack-bruteforce.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
#!/bin/bash

# Brute-force
# Example: hashcat -a 3 -m 0 example.hash ?a?a?a?a?a?a

# Function to handle hashcat execution and check for success
run_hashcat() {
local session="$1"
local hashmode="$2"
local mask="$3"
local workload="$4"
local status_timer="$5"
local hashcat_path="$6"
local hashcat_output=""

if [ "$status_timer" = "y" ]; then
hashcat_output=$("$hashcat_path/hashcat.exe" --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask")
else
hashcat_output=$("$hashcat_path/hashcat.exe" --session="$session" -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask")
fi

if echo "$hashcat_output" | grep -q "Cracked"; then
echo -e "${GREEN}Hashcat found the plaintext! Saving logs...${NC}"
sleep 2
save_logs
save_settings "$session" "" "" "$mask" ""
else
echo -e "${RED}Hashcat did not find the plaintext.${NC}"
sleep 2
fi
}


source windows/functions.sh
define_windows_parameters
Expand Down Expand Up @@ -69,12 +95,5 @@ echo -e "${GREEN}Restore >>${NC} $default_restorepath/$session"
echo -e "${GREEN}Command >>${NC} hashcat.exe --session="$session" --increment --increment-min="$min_length" --increment-max="$max_length" -m "$hashmode" hash.txt -a 6 -w "$workload" --outfile-format=2 -o plaintext.txt "$wordlist_path/$wordlist" "$mask""

# Execute hashcat with combined attack (wordlist + mask) and increment options
if [ "$status_timer" = "y" ]; then
"$hashcat_path/hashcat.exe" --session="$session" --status --status-timer=2 -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask"
else
"$hashcat_path/hashcat.exe" --session="$session" -m "$hashmode" hash.txt -a 3 -w "$workload" --outfile-format=2 -o plaintext.txt "$mask"
fi
run_hashcat "$session" "$hashmode" "$mask" "$workload" "$status_timer" "$hashcat_path"

# Save successful settings
save_settings "$session" "" "" "$mask" ""
save_logs
Loading

0 comments on commit 21bb8ca

Please sign in to comment.