Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config memory #23

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,9 @@ echo "
"
sleep 0.5
echo "- Upgrading Defenses 🛡️"
if ! ping -w 1 google.com &>/dev/null ; then
echo "- Failed to upgrade. Please check your internet connection."
sleep 2
exit 1
fi

# Download the hosts file and save it as "hosts"
wget --no-check-certificate -O /sdcard/hosts1 https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts &>/dev/null || abort "Failed to download hosts file."
wget --no-check-certificate -O /sdcard/hosts2 https://raw.githubusercontent.com/hagezi/dns-blocklists/main/hosts/pro.plus-compressed.txt &>/dev/null || abort "Failed to download hosts file."
wget --no-check-certificate -O /sdcard/hosts3 https://o0.pages.dev/Pro/hosts.txt &>/dev/null || abort "Failed to download hosts file."
wget --no-check-certificate -O /sdcard/hosts4 https://raw.githubusercontent.com/r-a-y/mobile-hosts/master/AdguardDNS.txt &>/dev/null || abort "Failed to download hosts file."
wget --no-check-certificate -O /sdcard/hosts5 https://raw.githubusercontent.com/r-a-y/mobile-hosts/refs/heads/master/AdguardMobileAds.txt &>/dev/null || abort "Failed to download hosts file."
wget --no-check-certificate -O /sdcard/hosts6 https://raw.githubusercontent.com/r-a-y/mobile-hosts/refs/heads/master/AdguardMobileSpyware.txt &>/dev/null || abort "Failed to download hosts file."
sleep 0.2
echo "- Preparing New weapons 🔫"

for j_cole in /system/etc/hosts /sdcard/hosts1 /sdcard/hosts2 /sdcard/hosts3 /sdcard/hosts4 /sdcard/hosts5 /sdcard/hosts6; do
cat "$j_cole"
echo ""
done | grep -vE '^[[:space:]]*#' | grep -vE '^[[:space:]]*$' | sort | uniq > "$MODDIR/system/etc/hosts"
sh "$MODDIR/system/bin/rmlwk" --update-hosts || abort "- Failed to update hosts."

# let's see if the file was downloaded or not.
if [ ! -f "/sdcard/hosts6" ]; then
echo "- Looks like there is a problem with some weapons, check your internet connection and try again"
else
string="description=Status: Protection is enabled ✅ | protection update date: $(date)"
sed -i "s/^description=.*/$string/g" $MODDIR/module.prop
echo "- Everthing is fine now, Enjoy 😉"
rm /sdcard/hosts*
fi
echo "- Everthing is fine now, Enjoy 😉"
115 changes: 49 additions & 66 deletions common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,32 @@ ui_print "
│░▀░▀░▀▀▀░░░░░▀░▀░▀░▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀░▀│
╚────────────────────────────────────────╝"
ui_print " Welcome to Re-Malwack installation wizard!"
sleep 0.5
sleep 0.2
ui_print ""
ui_print " ----------------------------------"
ui_print " \ "
ui_print ""
sleep 0.5
sleep 0.2
ui_print "- ⚙ Module Version: $(grep_prop version $TMPDIR/module.prop)"
sleep 0.5
sleep 0.2
ui_print "- 📱 Device Brand: $(getprop ro.product.brand)"
sleep 0.5
sleep 0.2
ui_print "- 📱 Device Model: $(getprop ro.product.model)"
sleep 0.5
sleep 0.2
ui_print "- 🤖 Android Version: $(getprop ro.build.version.release)"
sleep 0.5
sleep 0.2
ui_print "- ⚙ Device Arch: $(getprop ro.product.cpu.abi)"
sleep 0.5
sleep 0.2
ui_print "- 🛠 Kernel version: $(uname -r)"
sleep 0.5
sleep 0.2
ui_print "- ⌛ Current Time: $(date "+%d, %b - %H:%M %Z")"
ui_print ""
sleep 0.5
sleep 0.2
ui_print " /"
ui_print " ----------------------------------"
ui_print " "
sleep 1
ui_print "[INSTALLATION BEGINS]"
sleep 1
sleep 0.2

# rcm lore.
if ! $BOOTMODE; then
Expand All @@ -84,83 +83,67 @@ fi

# check for conflicts
ui_print "- Checking for conflicts"
tempFileToStoreConflicts=$(
if touch /data/local/tmp/tempFile; then
echo "/data/local/tmp/tempFile"
else
echo "/sdcard/tempFile"
fi
)
pm list packages | grep -q org.adaway && abort "- Adaway is detected, Please disable to prevent conflicts."

pm list packages | sed 's/package://' | grep -q org.adaway && abort "- Adaway is detected, Please disable to prevent conflicts."
for module in /data/adb/modules/*; do
module_id="$(grep_prop id ${module}/module.prop)"
# Skip our own module
[ "$module_id" == "Re-Malwack" ] && continue

for i in /data/adb/modules/*; do
# Skip this instance if we are in our own module directory
if [ "$(grep_prop id ${i}/module.prop)" == "Re-Malwack" ]; then
continue
fi
# Check for conflict by looking for a hosts file in the module
if [ -f "${i}/system/etc/hosts" ]; then
modules_count=$(($modules_count + 1))
# Save both the name and ID to the temp file (name|id format)
echo "$(grep_prop name ${i}/module.prop)|$(grep_prop id ${i}/module.prop)" >> $tempFileToStoreConflicts
if [ -f "${module}/system/etc/hosts" ]; then
module_name="$(grep_prop name ${module}/module.prop)"
ui_print "- Disabling conflicting module: $module_name"
touch "/data/adb/modules/$module_id/disable"
fi
done

if [ "$modules_count" -ge "1" ]; then
echo "- Notice: The following modules will be disabled to prevent conflicts:"
while IFS='|' read -r moduleName moduleID; do
echo "- $moduleName"
# Create the disable file in the corresponding module directory
touch "/data/adb/modules/$moduleID/disable"
done < $tempFileToStoreConflicts
fi


# make an bool to prevent extracting things if we dont have anything to extract...
if [ "$DO_WE_HAVE_ANYTHING_TO_EXTRACT" == "true" ]; then
unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2
fi

# let's check do we have internet or not.
ui_print "- Checking internet connection"
ping -w 2 google.com &>/dev/null || abort "- This module requires internet connection to download protections."
ping -c 1 -w 5 google.com &>/dev/null || abort "- This module requires internet connection to download protections."

# Download hosts files
ui_print "- Preparing Shields 🛡️"
mkdir -p $MODPATH/system/etc
counter=1
echo "$hostsFileURL" | while read -r url; do
# Skip empty lines
[ -n "$url" ] || continue

# Download using wget
wget --no-check-certificate -O "hosts${counter}" "$url" &>/dev/null || {
abort "- Failed to download hosts file from $url"
}
counter=$((counter + 1))
pids=""
while read -r url; do
if [ -n "$url" ]; then
wget --no-check-certificate -O "hosts${counter}" "$url" &>/dev/null &
pids="$pids $!"
counter=$((counter + 1))
fi
done < <(echo "$hostsFileURL")

# Wait for all downloads to complete
for pid in $pids; do
wait $pid || abort "- Download failed. Please check your internet connection and try again."
done

# Check if all files were downloaded successfully
for i in $(seq 1 $((counter-1))); do
if [ ! -f "hosts${i}" ]; then
abort "- Download failed. Please check your internet connection and try again."
fi
done

# Merge files into a single hosts file
mkdir -p $MODPATH/system/etc
ui_print "- Preparing weapons to kill malware 🔫"
{
for file in /system/etc/hosts hosts1 hosts2 hosts3 hosts4 hosts5 hosts6 ; do
[ -f "$file" ] && cat "$file"
echo ""
done
} | grep -vE '^[[:space:]]*#' | grep -vE '^[[:space:]]*$' | sort | uniq > $MODPATH/system/etc/hosts

# let's see if the file was downloaded or not.
if [ ! -f "hosts6" ]; then
abort "- Looks like there is a problem with some weapons, maybe check your internet connection?"
else
ui_print "- Your device is now armed against ads, malware and more 🛡"
sleep 0.5
cat /system/etc/hosts hosts* 2>/dev/null | sed -e '/^[[:space:]]*#/d' -e '/^[[:space:]]*$/d' -e 's/^[[:space:]]*//g' | sort -u > $MODPATH/system/etc/hosts
ui_print "- Your device is now armed against ads, malware and more 🛡"

# Add a persistent directory to save configuration
if [ ! -f "/data/adb/Re-Malwack/config.sh" ]; then
mkdir /data/adb/Re-Malwack
echo -e "block_porn=0\nblock_gambling=0\nblock_fakenews=0" > "/data/adb/Re-Malwack/config.sh"
fi

# set perms
# set permissions
chmod 644 $MODPATH/system/etc/hosts
chmod 755 $MODPATH/system/bin/rmlwk
chmod 755 $MODPATH/action.sh
# cleanup
rm -rf $tempFileToStoreConflicts
chmod 755 "/data/adb/Re-Malwack/config.sh"
27 changes: 10 additions & 17 deletions service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
# Variables
MODDIR="/data/adb/modules/Re-Malwack"
HOSTS_FILE="/system/etc/hosts"

while true; do
# Current timestamp
string="description=Status: Protection is enabled ✅ | Protection update date: $(date)"

# Check if hosts file contains blocked entries
if grep -q '0.0.0.0' "$HOSTS_FILE"; then
# Update the module description
sed -i "s/^description=.*/$string/g" "$MODDIR/module.prop"
else
# Update the module description if no entries are blocked
sed -i "s/^description=.*/description=Status: disabled due to no blocked entries ❌/g" "$MODDIR/module.prop"
fi

# Wait for 5 minutes before the next refresh
sleep 300
done
string="description=Status: Protection is enabled ✅ | Protection update date: $(date)"

# Check if hosts file contains blocked entries
if grep -q '0.0.0.0' "$HOSTS_FILE"; then
# Update the module description
sed -i "s/^description=.*/$string/g" "$MODDIR/module.prop"
else
# Update the module description if no entries are blocked
sed -i "s/^description=.*/description=Status: disabled due to no blocked entries ❌/g" "$MODDIR/module.prop"
fi
Loading