0% acharam este documento útil (0 voto)
14 visualizações37 páginas

Script API

O documento é um script em Bash que realiza uma série de testes em um dispositivo Android usando a API Termux, incluindo envio de SMS, captura de fotos, verificação de GPS, envio de mensagens pelo WhatsApp, e testes de hardware e software. Ele também inclui uma verificação de segurança que analisa malware, arquivos duplicados e contatos, além de gerar relatórios sobre os testes realizados. O script é projetado para ser executado em um ambiente Termux e requer a instalação de várias dependências.

Enviado por

marcosv12011995
Direitos autorais
© © All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato PDF, TXT ou leia on-line no Scribd
0% acharam este documento útil (0 voto)
14 visualizações37 páginas

Script API

O documento é um script em Bash que realiza uma série de testes em um dispositivo Android usando a API Termux, incluindo envio de SMS, captura de fotos, verificação de GPS, envio de mensagens pelo WhatsApp, e testes de hardware e software. Ele também inclui uma verificação de segurança que analisa malware, arquivos duplicados e contatos, além de gerar relatórios sobre os testes realizados. O script é projetado para ser executado em um ambiente Termux e requer a instalação de várias dependências.

Enviado por

marcosv12011995
Direitos autorais
© © All Rights Reserved
Levamos muito a sério os direitos de conteúdo. Se você suspeita que este conteúdo é seu, reivindique-o aqui.
Formatos disponíveis
Baixe no formato PDF, TXT ou leia on-line no Scribd

#!

/bin/bash

# Configurações
EMAIL="[email protected]"
NUMERO_CELULAR="+551199999999"
DESTINATARIO_WHATSAPP="+551188888888"

# Verifica se Termux API está instalado


if ! command -v termux-battery-status &> /dev/null; then
echo "Instale Termux-API primeiro: pkg install termux-api"
exit 1
fi

# Função para registrar resultados


log() {
echo -e "[$(date '+%H:%M:%S')] $1" >> termux_test.log
echo -e "$1"
}

# Teste de SMS
test_sms() {
log "\n Testando envio de SMS..."
termux-sms-send -n "$NUMERO_CELULAR" "Teste de SMS do Termux
API - $(date)"
log " SMS enviado para $NUMERO_CELULAR"
}

# Teste de Câmera
test_camera() {
log "\n Testando câmera..."
termux-camera-photo -c 0 camera_test.jpg
if [ -f camera_test.jpg ]; then
log " Foto tirada com sucesso (camera_test.jpg)"
else
log " Falha ao acessar a câmera"
fi
}

# Teste de GPS
test_gps() {
log "\n Testando GPS..."
gps_data=$(termux-location)
if [ -z "$gps_data" ]; then
log " Falha ao obter localização"
else
log " Dados de GPS:"
echo "$gps_data" | jq '.' >> termux_test.log
echo "$gps_data" | jq '.latitude, .longitude'
fi
}

# Teste de WhatsApp
test_whatsapp() {
log "\n Testando WhatsApp..."
termux-contact-list | grep -i "$DESTINATARIO_WHATSAPP" > /dev/null
if [ $? -eq 0 ]; then
termux-share -a view -t "Teste do Termux API" -c "Mensagem de teste
enviada em $(date)" "$DESTINATARIO_WHATSAPP"
log " Mensagem enviada para WhatsApp"
else
log " Contato não encontrado na lista"
fi
}

# Teste de Email
test_email() {
log "\n Testando envio de email..."
termux-open --send-email "$EMAIL" \
--subject "Teste Termux API" \
--body "Este é um teste automático do Termux API\n\nData:
$(date)\n\nBateria: $(termux-battery-status | jq -r '.percentage')%"
log " Email enviado para $EMAIL"
}

# Teste de Sensores
test_sensors() {
log "\n Testando sensores..."
log "Sensores disponíveis:"
termux-sensor -l >> termux_test.log

log "\nTestando acelerômetro:"


termux-sensor -s "accelerometer" -n 2
}

# Teste de Microfone
test_microphone() {
log "\n Testando microfone..."
termux-microphone-record -f mic_test.aac -l 3
if [ -f mic_test.aac ]; then
log " Gravação realizada (mic_test.aac)"
else
log " Falha ao acessar microfone"
fi
}

# Teste de Vibração
test_vibration() {
log "\n Testando vibração..."
termux-vibrate -d 1000
log " Vibração ativada por 1 segundo"
}

# Menu principal
main() {
echo "" > termux_test.log
log " Iniciando testes do Termux API - $(date)"

test_sms
test_camera
test_gps
test_whatsapp
test_email
test_sensors
test_microphone
test_vibration

log "\n Resumo dos testes:"


grep -E '|' termux_test.log

log "\n Log completo salvo em termux_test.log"


}

main
#!/bin/bash

# Configurações
EMAIL="[email protected]"
NUMERO_CELULAR="+551199999999"
DESTINATARIO_WHATSAPP="+551188888888"
ARQUIVO_LOG="termux_test_$(date +%Y%m%d_%H%M%S).log"

# Cores para saída


RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Função para registrar resultados


log() {
echo -e "[$(date '+%H:%M:%S')] $1" | tee -a $ARQUIVO_LOG
}

# Função para testar e registrar resultado


test_component() {
local component_name=$1
shift
log "${BLUE}Testando ${component_name}...${NC}"
if "$@" >> $ARQUIVO_LOG 2>&1; then
log "${GREEN} ${component_name} funcionando${NC}"
return 0
else
log "${RED} Falha no ${component_name}${NC}"
return 1
fi
}
# Verificar dependências
check_dependencies() {
local missing=()
local dependencies=("termux-api" "jq" "curl" "nmap" "git")

for dep in "${dependencies[@]}"; do


if ! command -v $dep &> /dev/null; then
missing+=("$dep")
fi
done

if [ ${#missing[@]} -gt 0 ]; then


log "${YELLOW}Instalando dependências faltantes...${NC}"
pkg install -y "${missing[@]}" | tee -a $ARQUIVO_LOG
fi
}

## Testes de Hardware ##

test_sms() {
test_component "SMS" termux-sms-send -n "$NUMERO_CELULAR"
"Teste de SMS do Termux API - $(date)"
}

test_camera() {
test_component "Câmera" termux-camera-photo -c 0 camera_test.jpg
[ -f camera_test.jpg ] && rm camera_test.jpg
}

test_gps() {
local gps_data=$(termux-location)
test_component "GPS" [ -n "$gps_data" ] && echo "$gps_data" | jq '.'
}

test_microphone() {
test_component "Microfone" termux-microphone-record -f mic_test.aac -l 2
[ -f mic_test.aac ] && rm mic_test.aac
}

test_sensors() {
test_component "Sensores" termux-sensor -l
}

test_vibration() {
test_component "Vibração" termux-vibrate -d 500
}

## Testes de Sistema Operacional ##

test_cpu() {
test_component "CPU" grep -i "model name" /proc/cpuinfo | head -n 1
}

test_memory() {
test_component "Memória" free -h
}

test_storage() {
test_component "Armazenamento" df -h
}

test_network() {
test_component "Conexão de rede" ping -c 3 google.com
}

test_packages() {
test_component "Gerenciamento de pacotes" pkg list-installed
}

test_processes() {
test_component "Processos em execução" ps aux
}

test_filesystem() {
test_component "Sistema de arquivos" ls -l /
}

test_kernel() {
test_component "Versão do Kernel" uname -a
}

test_users() {
test_component "Usuários do sistema" whoami
}

test_environment() {
test_component "Variáveis de ambiente" printenv
}

## Testes Avançados ##

test_termux_api() {
test_component "Termux API" termux-battery-status
}

test_python() {
test_component "Python" python3 --version
}

test_git() {
test_component "Git" git --version
}
test_ssh() {
test_component "SSH" ssh -V
}

test_web() {
test_component "Conexão Web" curl -I https://google.com
}

test_ports() {
test_component "Verificação de portas" nmap localhost
}

## Funções de Relatório ##

generate_report() {
log "\n${BLUE}=== RELATÓRIO FINAL ===${NC}"

local total_tests=$(grep -c "Testando" $ARQUIVO_LOG)


local success_tests=$(grep -c "" $ARQUIVO_LOG)
local failed_tests=$(grep -c "" $ARQUIVO_LOG)

log "Total de testes realizados: $total_tests"


log "Testes bem-sucedidos: ${GREEN}$success_tests${NC}"
log "Testes com falha: ${RED}$failed_tests${NC}"

if [ $failed_tests -gt 0 ]; then


log "\n${RED}=== TESTES COM FALHA ===${NC}"
grep -B 1 "" $ARQUIVO_LOG
fi

log "\n${GREEN}=== TESTES BEM-SUCEDIDOS ===${NC}"


grep -B 1 "" $ARQUIVO_LOG | grep -v ""

log "\nLog completo disponível em: $ARQUIVO_LOG"


}

# Menu principal
main() {
echo -e "${BLUE}=== TESTE COMPLETO DO TERMUX ===${NC}"
echo -e "${YELLOW}Iniciando testes em $(date)${NC}"
echo -e "Log sendo salvo em: ${YELLOW}$ARQUIVO_LOG${NC}"

check_dependencies

# Testes de Hardware
echo -e "\n${BLUE}=== TESTES DE HARDWARE ===${NC}"
test_sms
test_camera
test_gps
test_microphone
test_sensors
test_vibration
# Testes de Sistema Operacional
echo -e "\n${BLUE}=== TESTES DO SISTEMA OPERACIONAL ===${NC}"
test_cpu
test_memory
test_storage
test_network
test_packages
test_processes
test_filesystem
test_kernel
test_users
test_environment

# Testes Avançados
echo -e "\n${BLUE}=== TESTES AVANÇADOS ===${NC}"
test_termux_api
test_python
test_git
test_ssh
test_web
test_ports

generate_report
}

main
#!/bin/bash

# Configurações de segurança
LOG_FILE="security_scan_$(date +%Y%m%d_%H%M%S).log"
QUARANTINE_DIR="$HOME/security_quarantine"
WHITELIST=("trusted_app1" "trusted_app2") # Adicione seus apps confiáveis

# Cores para saída


RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Criar diretório de quarentena


mkdir -p "$QUARANTINE_DIR"

# Função de log
log() {
echo -e "[$(date '+%H:%M:%S')] $1" | tee -a "$LOG_FILE"
}

# Verificar dependências
check_dependencies() {
local deps=("termux-api" "jq" "curl" "git" "python" "rkhunter" "clamav"
"fdupes" "exiftool")
local missing=()

for dep in "${deps[@]}"; do


if ! command -v $dep &> /dev/null; then
missing+=("$dep")
fi
done

if [ ${#missing[@]} -gt 0 ]; then


log "${YELLOW}Instalando dependências faltantes...${NC}"
pkg install -y "${missing[@]}" || {
log "${RED}Falha ao instalar dependências${NC}";
exit 1;
}
fi
}

# Anti-malware scan
scan_malware() {
log "${BLUE}Iniciando varredura de malware...${NC}"

# Verificar rootkits com rkhunter


log "Verificando rootkits..."
rkhunter --check --sk --quiet | tee -a "$LOG_FILE"

# Verificar vírus com ClamAV


log "Verificando vírus..."
clamscan -r --bell -i / | tee -a "$LOG_FILE"

# Verificar processos suspeitos


log "Verificando processos suspeitos..."
ps aux | grep -E '(\.tmp|\.sh|coinminer|miner|httpdns|dnschanger)' | grep -v
grep | tee -a "$LOG_FILE"

# Verificar conexões suspeitas


log "Verificando conexões de rede..."
netstat -tuln | grep -E '(6667|2339|4444|5555|6666|1337|31337)' | tee -a
"$LOG_FILE"
}

# Verificação de arquivos duplicados


find_duplicates() {
log "${BLUE}Procurando arquivos duplicados...${NC}"

# Usar fdupes para encontrar duplicados


fdupes -r "$HOME" > duplicates.list

if [ -s duplicates.list ]; then
log "${YELLOW}Arquivos duplicados encontrados:${NC}"
cat duplicates.list | tee -a "$LOG_FILE"
# Mover para quarentena
while read -r file; do
if [ -f "$file" ]; then
mv "$file" "$QUARANTINE_DIR/"
log "Movido para quarentena: $file"
fi
done < duplicates.list
else
log "${GREEN}Nenhum arquivo duplicado encontrado.${NC}"
fi
}

# Verificar contatos duplicados


check_duplicate_contacts() {
log "${BLUE}Verificando contatos duplicados...${NC}"

termux-contact-list | jq 'group_by(.name) | map(select(length > 1)) | .[]' >


duplicate_contacts.json

if [ -s duplicate_contacts.json ]; then
log "${YELLOW}Contatos duplicados encontrados:${NC}"
jq -r '.[0].name' duplicate_contacts.json | tee -a "$LOG_FILE"

# Opção para remover duplicados


read -p "Remover contatos duplicados? [s/N] " choice
if [[ $choice =~ ^[Ss]$ ]]; then
jq -r '.[1:] | .[]._id' duplicate_contacts.json | while read id; do
termux-contact-remove "$id" && log "Removido contato ID: $id"
done
fi
else
log "${GREEN}Nenhum contato duplicado encontrado.${NC}"
fi
}

# Verificar mensagens duplicadas


check_duplicate_sms() {
log "${BLUE}Verificando mensagens duplicadas...${NC}"

termux-sms-list -l 1000 | jq 'group_by(.body) | map(select(length > 1)) | .[]' >


duplicate_sms.json

if [ -s duplicate_sms.json ]; then
log "${YELLOW}Mensagens duplicadas encontradas:${NC}"
jq -r '.[0].body' duplicate_sms.json | head -n 5 | tee -a "$LOG_FILE"
else
log "${GREEN}Nenhuma mensagem duplicada encontrada.${NC}"
fi
}

# Verificar fotos duplicadas


check_duplicate_photos() {
log "${BLUE}Verificando fotos duplicadas...${NC}"

# Usar exiftool para encontrar fotos similares


find ~/storage/dcim -type f -iname "*.jpg" -o -iname "*.png" | while read file;
do
exiftool -q -q -ImageSize -FileSize "$file"
done | sort | uniq -d > duplicate_photos.list

if [ -s duplicate_photos.list ]; then
log "${YELLOW}Fotos duplicadas encontradas:${NC}"
head -n 5 duplicate_photos.list | tee -a "$LOG_FILE"

# Mover para quarentena


while read -r photo; do
if [ -f "$photo" ]; then
mv "$photo" "$QUARANTINE_DIR/"
log "Movido para quarentena: $photo"
fi
done < duplicate_photos.list
else
log "${GREEN}Nenhuma foto duplicada encontrada.${NC}"
fi
}

# Sistema anti-hacking
anti_hacking() {
log "${BLUE}Iniciando verificações de segurança...${NC}"

# Verificar pacotes desconhecidos


log "Verificando pacotes não autorizados..."
pkg list-installed | grep -Ev "$(echo "${WHITELIST[@]}" | tr ' ' '|')" | tee -a
"$LOG_FILE"

# Verificar arquivos SUID suspeitos


log "Verificando arquivos SUID..."
find / -perm -4000 -type f 2>/dev/null | grep -Ev '/system/bin/|/system/xbin/' |
tee -a "$LOG_FILE"

# Verificar portas abertas


log "Verificando portas abertas..."
netstat -tuln | grep -v '127.0.0.1' | tee -a "$LOG_FILE"

# Verificar tentativas de login


log "Verificando tentativas de login..."
logcat -d | grep -i 'failed login' | tail -n 10 | tee -a "$LOG_FILE"

# Verificar arquivos ocultos


log "Verificando arquivos ocultos suspeitos..."
find ~ -name '.*' -type f -size +1M | tee -a "$LOG_FILE"
}

# Limpeza de segurança
cleanup() {
log "${BLUE}Realizando limpeza de segurança...${NC}"

# Limpar cache
log "Limpando cache..."
rm -rf ~/.cache/*

# Limpar arquivos temporários


log "Limpando arquivos temporários..."
find ~ -name '*.tmp' -delete

# Limpar histórico
log "Limpando histórico..."
history -c
rm ~/.bash_history

log "${GREEN}Limpeza concluída.${NC}"


}

# Menu principal
main_menu() {
clear
echo -e "${BLUE}=== TERMUX SECURITY SUITE ==="
echo -e "1. Varredura completa de malware"
echo -e "2. Verificar arquivos duplicados"
echo -e "3. Verificar contatos duplicados"
echo -e "4. Verificar mensagens duplicadas"
echo -e "5. Verificar fotos duplicadas"
echo -e "6. Sistema anti-hacking"
echo -e "7. Limpeza de segurança"
echo -e "8. Executar todas as verificações"
echo -e "0. Sair${NC}"

read -p "Selecione uma opção: " choice

case $choice in
1) scan_malware ;;
2) find_duplicates ;;
3) check_duplicate_contacts ;;
4) check_duplicate_sms ;;
5) check_duplicate_photos ;;
6) anti_hacking ;;
7) cleanup ;;
8)
scan_malware
find_duplicates
check_duplicate_contacts
check_duplicate_sms
check_duplicate_photos
anti_hacking
cleanup
;;
0) exit 0 ;;
*) echo -e "${RED}Opção inválida${NC}" ;;
esac

read -p "Pressione Enter para continuar..."


main_menu
}

# Inicialização
check_dependencies
main_menu
#!/bin/bash

# Configurações
EMAIL="[email protected]"
NUMERO_CELULAR="+551199999999"
DESTINATARIO_WHATSAPP="+551188888888"
ARQUIVO_LOG="termux_test_$(date +%Y%m%d_%H%M%S).log"
QUARANTINE_DIR="$HOME/security_quarantine"
WHITELIST=("termux" "com.termux" "com.android.shell") # Apps confiáveis

# Cores para saída


RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Criar diretório de quarentena


mkdir -p "$QUARANTINE_DIR"

# Função para registrar resultados


log() {
echo -e "[$(date '+%H:%M:%S')] $1" | tee -a $ARQUIVO_LOG
}

# Função para testar e registrar resultado


test_component() {
local component_name=$1
shift
log "${BLUE}Testando ${component_name}...${NC}"
if "$@" >> $ARQUIVO_LOG 2>&1; then
log "${GREEN} ${component_name} funcionando${NC}"
return 0
else
log "${RED} Falha no ${component_name}${NC}"
return 1
fi
}

# Verificar dependências
check_dependencies() {
local missing=()
local dependencies=("termux-api" "jq" "curl" "nmap" "git" "python" "rkhunter"
"clamav" "fdupes" "exiftool")

for dep in "${dependencies[@]}"; do


if ! command -v $dep &> /dev/null; then
missing+=("$dep")
fi
done

if [ ${#missing[@]} -gt 0 ]; then


log "${YELLOW}Instalando dependências faltantes...${NC}"
pkg install -y "${missing[@]}" | tee -a $ARQUIVO_LOG
fi
}

## Testes de Hardware ##

test_sms() {
test_component "SMS" termux-sms-send -n "$NUMERO_CELULAR"
"Teste de SMS do Termux API - $(date)"
}

test_camera() {
test_component "Câmera" termux-camera-photo -c 0 camera_test.jpg
[ -f camera_test.jpg ] && rm camera_test.jpg
}

test_gps() {
local gps_data=$(termux-location)
test_component "GPS" [ -n "$gps_data" ] && echo "$gps_data" | jq '.'
}

test_microphone() {
test_component "Microfone" termux-microphone-record -f mic_test.aac -l 2
[ -f mic_test.aac ] && rm mic_test.aac
}

test_sensors() {
test_component "Sensores" termux-sensor -l
}

test_vibration() {
test_component "Vibração" termux-vibrate -d 500
}

## Testes de Sistema Operacional ##

test_cpu() {
test_component "CPU" grep -i "model name" /proc/cpuinfo | head -n 1
}
test_memory() {
test_component "Memória" free -h
}

test_storage() {
test_component "Armazenamento" df -h
}

test_network() {
test_component "Conexão de rede" ping -c 3 google.com
}

test_packages() {
test_component "Gerenciamento de pacotes" pkg list-installed
}

test_processes() {
test_component "Processos em execução" ps aux
}

test_filesystem() {
test_component "Sistema de arquivos" ls -l /
}

test_kernel() {
test_component "Versão do Kernel" uname -a
}

test_users() {
test_component "Usuários do sistema" whoami
}

test_environment() {
test_component "Variáveis de ambiente" printenv
}

## Testes Avançados ##

test_termux_api() {
test_component "Termux API" termux-battery-status
}

test_python() {
test_component "Python" python3 --version
}

test_git() {
test_component "Git" git --version
}

test_ssh() {
test_component "SSH" ssh -V
}

test_web() {
test_component "Conexão Web" curl -I https://google.com
}

test_ports() {
test_component "Verificação de portas" nmap localhost
}

## Testes de Segurança Avançada ##

test_malware() {
log "${BLUE}Iniciando varredura de malware...${NC}"

# Verificar rootkits
test_component "Rootkits" rkhunter --check --sk --quiet

# Verificar vírus
test_component "Vírus" clamscan -r --bell -i "$HOME"

# Verificar processos suspeitos


log "Verificando processos suspeitos..."
ps aux | grep -E '(\.tmp|\.sh|coinminer|miner|httpdns|dnschanger)' | grep -v
grep | tee -a $ARQUIVO_LOG

# Verificar conexões suspeitas


log "Verificando conexões suspeitas..."
netstat -tuln | grep -E '(6667|2339|4444|5555|6666|1337|31337)' | tee -a
$ARQUIVO_LOG
}

test_duplicates() {
log "${BLUE}Procurando arquivos duplicados...${NC}"

# Arquivos duplicados
test_component "Arquivos duplicados" fdupes -r "$HOME" > duplicates.list
[ -s duplicates.list ] && log "${YELLOW}Arquivos duplicados encontrados.
Verifique duplicates.list${NC}"

# Contatos duplicados
log "Verificando contatos duplicados..."
termux-contact-list | jq 'group_by(.name) | map(select(length > 1)) | .[]' >
duplicate_contacts.json
[ -s duplicate_contacts.json ] && log "${YELLOW}Contatos duplicados
encontrados. Verifique duplicate_contacts.json${NC}"

# Fotos duplicadas
log "Verificando fotos duplicadas..."
find ~/storage/dcim -type f -iname "*.jpg" -o -iname "*.png" | while read file;
do
exiftool -q -q -ImageSize -FileSize "$file"
done | sort | uniq -d > duplicate_photos.list
[ -s duplicate_photos.list ] && log "${YELLOW}Fotos duplicadas
encontradas. Verifique duplicate_photos.list${NC}"
}

test_antihacking() {
log "${BLUE}Executando verificações anti-hacking...${NC}"

# Verificar pacotes não autorizados


log "Verificando pacotes não autorizados..."
pkg list-installed | grep -Ev "$(echo "${WHITELIST[@]}" | tr ' ' '|')" | tee -a
$ARQUIVO_LOG

# Verificar arquivos SUID suspeitos


log "Verificando arquivos SUID suspeitos..."
find / -perm -4000 -type f 2>/dev/null | grep -Ev '/system/bin/|/system/xbin/' |
tee -a $ARQUIVO_LOG

# Verificar arquivos ocultos grandes


log "Verificando arquivos ocultos suspeitos..."
find ~ -name '.*' -type f -size +1M | tee -a $ARQUIVO_LOG
}

clean_security() {
log "${BLUE}Realizando limpeza de segurança...${NC}"

# Limpar cache
test_component "Limpeza de cache" rm -rf ~/.cache/*

# Limpar arquivos temporários


test_component "Limpeza de temporários" find ~ -name '*.tmp' -delete

# Limpar histórico
test_component "Limpeza de histórico" history -c && rm ~/.bash_history

log "${GREEN}Limpeza de segurança concluída${NC}"


}

## Funções de Relatório ##

generate_report() {
log "\n${BLUE}=== RELATÓRIO FINAL ===${NC}"

local total_tests=$(grep -c "Testando" $ARQUIVO_LOG)


local success_tests=$(grep -c "" $ARQUIVO_LOG)
local failed_tests=$(grep -c "" $ARQUIVO_LOG)

log "Total de testes realizados: $total_tests"


log "Testes bem-sucedidos: ${GREEN}$success_tests${NC}"
log "Testes com falha: ${RED}$failed_tests${NC}"

if [ $failed_tests -gt 0 ]; then


log "\n${RED}=== TESTES COM FALHA ===${NC}"
grep -B 1 "" $ARQUIVO_LOG
fi

log "\n${GREEN}=== TESTES BEM-SUCEDIDOS ===${NC}"


grep -B 1 "" $ARQUIVO_LOG | grep -v ""

# Resumo de segurança
log "\n${YELLOW}=== ALERTAS DE SEGURANÇA ===${NC}"
grep -E 'malware|suspeitos|não autorizados|Rootkits|Vírus'
$ARQUIVO_LOG

log "\nLog completo disponível em: $ARQUIVO_LOG"


}

# Menu principal
main() {
echo -e "${BLUE}=== TESTE COMPLETO DO TERMUX ===${NC}"
echo -e "${YELLOW}Iniciando testes em $(date)${NC}"
echo -e "Log sendo salvo em: ${YELLOW}$ARQUIVO_LOG${NC}"

check_dependencies

# Testes de Hardware
echo -e "\n${BLUE}=== TESTES DE HARDWARE ===${NC}"
test_sms
test_camera
test_gps
test_microphone
test_sensors
test_vibration

# Testes de Sistema Operacional


echo -e "\n${BLUE}=== TESTES DO SISTEMA OPERACIONAL ===${NC}"
test_cpu
test_memory
test_storage
test_network
test_packages
test_processes
test_filesystem
test_kernel
test_users
test_environment

# Testes Avançados
echo -e "\n${BLUE}=== TESTES AVANÇADOS ===${NC}"
test_termux_api
test_python
test_git
test_ssh
test_web
test_ports

# Testes de Segurança
echo -e "\n${RED}=== TESTES DE SEGURANÇA ===${NC}"
test_malware
test_duplicates
test_antihacking
clean_security

generate_report
}

main
#!/bin/bash

# Configurações
ARQUIVO_LOG="termux_full_test_$(date +%Y%m%d_%H%M%S).log"
QUARANTINE_DIR="$HOME/security_quarantine"
TEST_SERVER="google.com"
SPEEDTEST_SERVER="--server-id=2927" # Servidor recomendado (mude
conforme sua região)

# Cores para saída


RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color

# Criar diretórios necessários


mkdir -p "$QUARANTINE_DIR"

# Função para registrar resultados


log() {
echo -e "[$(date '+%H:%M:%S')] $1" | tee -a "$ARQUIVO_LOG"
}

# Função para testar componentes


test_component() {
local component_name="$1"
shift
log "${CYAN}Testando ${component_name}...${NC}"
if "$@" >> "$ARQUIVO_LOG" 2>&1; then
log "${GREEN} ${component_name} funcionando${NC}"
return 0
else
log "${RED} Falha no ${component_name}${NC}"
return 1
fi
}
# Verificar e instalar dependências
check_dependencies() {
local deps=("termux-api" "jq" "curl" "nmap" "git" "python" "rkhunter"
"clamav" "fdupes" "exiftool" "speedtest-cli" "procps" "htop")
local missing=()

log "${BLUE}Verificando dependências...${NC}"


for dep in "${deps[@]}"; do
if ! command -v "$dep" &> /dev/null; then
missing+=("$dep")
fi
done

if [ ${#missing[@]} -gt 0 ]; then


log "${YELLOW}Instalando dependências faltantes...${NC}"
pkg install -y "${missing[@]}" || {
log "${RED}Falha ao instalar dependências${NC}";
return 1;
}
fi
}

### TESTES DE REDE ###


test_network() {
log "${PURPLE}=== TESTES DE REDE ===${NC}"

# Teste de ping básico


test_component "Ping básico" ping -c 4 "$TEST_SERVER"

# Teste de ping avançado


log "${CYAN}Teste de ping avançado...${NC}"
ping -c 10 "$TEST_SERVER" | tee -a "$ARQUIVO_LOG" | grep -E
'rtt|packet loss'

# Teste de velocidade (download/upload)


log "${CYAN}Testando velocidade da rede...${NC}"
speedtest-cli "$SPEEDTEST_SERVER" --simple | tee -a
"$ARQUIVO_LOG"

# Teste de portas abertas


test_component "Varredura de portas" nmap -Pn -T4 localhost

# Teste de DNS
test_component "Resolução DNS" dig "$TEST_SERVER" +short

# Teste de latência HTTP


test_component "Latência HTTP" curl -o /dev/null -s -w 'Tempo total:
%{time_total}s\n' "https://$TEST_SERVER"
}

### TESTES DE MEMÓRIA ###


test_memory() {
log "${PURPLE}=== TESTES DE MEMÓRIA ===${NC}"

# Memória RAM total e usada


log "${CYAN}Status da memória RAM:${NC}"
free -h | tee -a "$ARQUIVO_LOG"

# Varredura completa da RAM


log "${CYAN}Varredura da memória RAM...${NC}"
grep -E 'MemTotal|MemFree|MemAvailable|Buffers|Cached' /proc/meminfo
| tee -a "$ARQUIVO_LOG"

# Teste de estresse da RAM


log "${CYAN}Teste de estresse na RAM...${NC}"
if command -v stress-ng &> /dev/null; then
stress-ng --vm 1 --vm-bytes 80% --timeout 30s | tee -a
"$ARQUIVO_LOG"
else
log "${YELLOW}stress-ng não instalado. Instale para teste completo de
RAM.${NC}"
fi

# Limpeza de RAM
log "${CYAN}Limpando memória RAM...${NC}"
sync && echo 3 > /proc/sys/vm/drop_caches
log "${GREEN}Memória RAM limpa${NC}"

# Memória interna
log "${CYAN}Varredura de memória interna...${NC}"
df -h /data /system /storage | tee -a "$ARQUIVO_LOG"

# Arquivos grandes
log "${CYAN}Buscando arquivos grandes (>100MB)...${NC}"
find /storage /data -type f -size +100M -exec du -h {} + 2>/dev/null | sort -rh |
head -n 20 | tee -a "$ARQUIVO_LOG"
}

### TESTES DE HARDWARE ###


test_hardware() {
log "${PURPLE}=== TESTES DE HARDWARE ===${NC}"

# CPU
test_component "Informações da CPU" lscpu || grep -i "model name"
/proc/cpuinfo

# Bateria
test_component "Status da bateria" termux-battery-status

# Sensores
test_component "Sensores disponíveis" termux-sensor -l

# GPS
test_component "Localização GPS" termux-location

# Câmera
test_component "Câmera" termux-camera-photo -c 0 camera_test.jpg &&
rm camera_test.jpg

# Microfone
test_component "Microfone" termux-microphone-record -f mic_test.aac -l 2
&& rm mic_test.aac

# Vibração
test_component "Vibração" termux-vibrate -d 500
}

### TESTES DE SISTEMA ###


test_system() {
log "${PURPLE}=== TESTES DE SISTEMA ===${NC}"

# Kernel
test_component "Versão do Kernel" uname -a

# Uptime
test_component "Tempo de atividade" uptime

# Processos
log "${CYAN}Processos em execução:${NC}"
ps aux | head -n 15 | tee -a "$ARQUIVO_LOG"

# Temperatura (se disponível)


test_component "Temperatura do dispositivo" cat
/sys/class/thermal/thermal_zone*/temp

# Pacotes instalados
log "${CYAN}Pacotes instalados:${NC}"
pkg list-installed | wc -l | tee -a "$ARQUIVO_LOG"
}

### TESTES DE SEGURANÇA ###


test_security() {
log "${PURPLE}=== TESTES DE SEGURANÇA ===${NC}"

# Rootkits
test_component "Verificação de rootkits" rkhunter --check --sk --quiet

# Vírus
test_component "Varredura de vírus" clamscan -r --bell -i "$HOME"

# Arquivos suspeitos
log "${CYAN}Buscando arquivos suspeitos...${NC}"
find /data /storage -type f \( -name "*.exe" -o -name "*.bat" -o -name "*.sh" \)
-exec ls -la {} + 2>/dev/null | tee -a "$ARQUIVO_LOG"
}
### LIMPEZA DO SISTEMA ###
clean_system() {
log "${PURPLE}=== LIMPEZA DO SISTEMA ===${NC}"

# Cache
test_component "Limpeza de cache" rm -rf ~/.cache/*

# Temporários
test_component "Limpeza de arquivos temporários" find /data /storage -
name "*.tmp" -delete 2>/dev/null

# Thumbnails
test_component "Limpeza de thumbnails" find /storage -type f -name
".thumbnails" -exec rm -rf {} +

# RAM
test_component "Otimização de memória RAM" sync && echo 3 >
/proc/sys/vm/drop_caches

# Pacotes obsoletos
test_component "Limpeza de pacotes" pkg autoclean

log "${GREEN}Limpeza do sistema concluída${NC}"


}

### RELATÓRIO FINAL ###


generate_report() {
log "\n${PURPLE}=== RELATÓRIO FINAL ===${NC}"

# Resumo estatístico
local total_tests=$(grep -c "Testando" "$ARQUIVO_LOG")
local success_tests=$(grep -c "" "$ARQUIVO_LOG")
local failed_tests=$(grep -c "" "$ARQUIVO_LOG")

log "Total de testes realizados: $total_tests"


log "Testes bem-sucedidos: ${GREEN}$success_tests${NC}"
log "Testes com falha: ${RED}$failed_tests${NC}"

# Alertas importantes
if [ "$failed_tests" -gt 0 ]; then
log "\n${RED}=== TESTES COM FALHA ===${NC}"
grep -B 1 "" "$ARQUIVO_LOG"
fi

# Problemas de segurança
log "\n${YELLOW}=== ALERTAS DE SEGURANÇA ===${NC}"
grep -iE "warning|error|suspeito|vírus|rootkit" "$ARQUIVO_LOG" | tail -n 10

# Desempenho
log "\n${CYAN}=== DESEMPENHO ===${NC}"
grep -E "speed|download|upload|latency|memory|cpu" "$ARQUIVO_LOG" |
tail -n 15

log "\nLog completo disponível em: ${YELLOW}$ARQUIVO_LOG${NC}"


}

### MENU PRINCIPAL ###


main_menu() {
clear
echo -e "${BLUE}=== TERMUX FULL TEST SUITE ==="
echo -e "1. Testes completos do sistema"
echo -e "2. Testes de rede"
echo -e "3. Testes de memória"
echo -e "4. Testes de hardware"
echo -e "5. Testes de segurança"
echo -e "6. Limpeza do sistema"
echo -e "7. Todos os testes + limpeza"
echo -e "0. Sair${NC}"

read -p "Selecione uma opção: " choice

case $choice in
1) run_full_tests ;;
2) test_network ;;
3) test_memory ;;
4) test_hardware ;;
5) test_security ;;
6) clean_system ;;
7) run_full_tests; clean_system ;;
0) exit 0 ;;
*) echo -e "${RED}Opção inválida${NC}"; sleep 1; main_menu ;;
esac
}

run_full_tests() {
check_dependencies
test_network
test_memory
test_hardware
test_system
test_security
generate_report
}

### EXECUÇÃO INICIAL ###


echo -e "${BLUE}=== TERMUX FULL TEST SUITE ==="
echo -e "Versão 2.0 - Teste completo do dispositivo"
echo -e "Log sendo salvo em: ${YELLOW}$ARQUIVO_LOG${NC}"

main_menu
#!/bin/bash

# Configurações
ARQUIVO_LOG="termux_full_test_$(date +%Y%m%d_%H%M%S).log"
QUARANTINE_DIR="$HOME/security_quarantine"
TEST_SERVER="google.com"
SPEEDTEST_SERVER="--server-id=2927" # Servidor recomendado (mude
conforme sua região)

# Cores para saída


RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color

# Criar diretórios necessários


mkdir -p "$QUARANTINE_DIR"

# Função para registrar resultados


log() {
echo -e "[$(date '+%H:%M:%S')] $1" | tee -a "$ARQUIVO_LOG"
}

# Função para testar componentes


test_component() {
local component_name="$1"
shift
log "${CYAN}Testando ${component_name}...${NC}"
if "$@" >> "$ARQUIVO_LOG" 2>&1; then
log "${GREEN} ${component_name} funcionando${NC}"
return 0
else
log "${RED} Falha no ${component_name}${NC}"
return 1
fi
}

## TESTES DE HARDWARE AVANÇADO ##


test_vibration() {
log "${BLUE}Testando vibração...${NC}"
for i in {100..500..100}; do
termux-vibrate -d $i
sleep 1
done
log "${GREEN}Teste de vibração concluído${NC}"
}

test_bluetooth() {
log "${BLUE}Testando Bluetooth...${NC}"
if termux-bluetooth-status | grep -q "enabled"; then
log "${GREEN}Bluetooth está ativado${NC}"
termux-bluetooth-devices | tee -a "$ARQUIVO_LOG"
else
log "${YELLOW}Bluetooth está desativado${NC}"
fi
}

test_flashlight() {
log "${BLUE}Testando lanterna...${NC}"
termux-torch on && sleep 2 && termux-torch off
log "${GREEN}Teste de lanterna concluído${NC}"
}

test_airplane_mode() {
log "${BLUE}Verificando modo avião...${NC}"
termux-airplane-mode | tee -a "$ARQUIVO_LOG"
}

test_battery_saver() {
log "${BLUE}Verificando modo economia de bateria...${NC}"
termux-battery-status | jq '.power_saver' | tee -a "$ARQUIVO_LOG"
}

## TESTES DE TELA ##
test_screen() {
log "${PURPLE}=== TESTES DE TELA ==="

# Não é possível verificar pixels mortos via terminal


log "${YELLOW}Para testar pixels mortos, execute manualmente:"
log "1. Abra um app de tela cheia com cores sólidas"
log "2. Verifique pontos que não mudam de cor${NC}"

# Teste de brilho
log "${CYAN}Testando ajuste de brilho...${NC}"
for brightness in 50 100 150 200 255; do
termux-brightness $brightness
sleep 1
done
termux-brightness auto

# Teste de cores (simplificado)


log "${CYAN}Exibindo cores de teste...${NC}"
for color in "red" "green" "blue" "white" "black"; do
termux-toast -b $color -c white -g top "Cor $color"
sleep 1
done
}

## TESTES DE CÂMERA AVANÇADOS ##


test_camera_advanced() {
log "${PURPLE}=== TESTES AVANÇADOS DE CÂMERA ==="

# Câmera traseira
test_component "Câmera traseira" termux-camera-photo -c 0
rear_camera.jpg
[ -f rear_camera.jpg ] && {
log "${GREEN}Foto da câmera traseira salva em rear_camera.jpg${NC}"
exiftool rear_camera.jpg | grep -E 'Camera|Resolution' | tee -a
"$ARQUIVO_LOG"
rm rear_camera.jpg
}

# Câmera frontal (se disponível)


test_component "Câmera frontal" termux-camera-photo -c 1
front_camera.jpg
[ -f front_camera.jpg ] && {
log "${GREEN}Foto da câmera frontal salva em front_camera.jpg${NC}"
exiftool front_camera.jpg | grep -E 'Camera|Resolution' | tee -a
"$ARQUIVO_LOG"
rm front_camera.jpg
}

# Teste de flash
log "${CYAN}Testando flash...${NC}"
termux-torch on && sleep 2 && termux-torch off
}

## TESTES DE ÁUDIO COMPLETO ##


test_audio_full() {
log "${PURPLE}=== TESTES COMPLETOS DE ÁUDIO ==="

# Alto-falante
log "${CYAN}Testando alto-falante...${NC}"
termux-tts-speak "Teste do alto-falante" --engine "speech"

# Microfone
test_component "Microfone" termux-microphone-record -f audio_test.aac -l
3
[ -f audio_test.aac ] && {
log "${GREEN}Gravação de áudio salva em audio_test.aac${NC}"
rm audio_test.aac
}

# Fone de ouvido (não é possível testar diretamente)


log "${YELLOW}Para testar fone de ouvido:"
log "1. Conecte o fone"
log "2. Reproduza um áudio"
log "3. Verifique se o som sai no fone${NC}"
}

## TESTES DE BOTÕES ##
test_buttons() {
log "${PURPLE}=== TESTES DE BOTÕES ==="

log "${YELLOW}Para testar botões físicos:"


log "1. Botão de volume: Ajuste o volume"
log "2. Botão de power: Bloqueie/desbloqueie a tela"
log "3. Verifique a resposta do dispositivo${NC}"
}

## TESTES DE CONECTIVIDADE AVANÇADA ##


test_connectivity_full() {
log "${PURPLE}=== TESTES DE CONECTIVIDADE ==="

# Wi-Fi
test_component "Conexão Wi-Fi" termux-wifi-connectioninfo

# Bluetooth (já testado anteriormente)

# GPS
test_component "GPS" termux-location

# Dados móveis
log "${CYAN}Verificando dados móveis...${NC}"
termux-telephony-cellinfo | tee -a "$ARQUIVO_LOG"
}

## TESTES DE SENSORES COMPLETOS ##


test_sensors_full() {
log "${PURPLE}=== TESTES DE SENSORES ==="

# Listar todos os sensores


test_component "Lista de sensores" termux-sensor -l

# Testar sensores específicos


for sensor in "accelerometer" "gyroscope" "light" "proximity"
"magnetic_field"; do
log "${CYAN}Testando sensor $sensor...${NC}"
termux-sensor -s $sensor -n 2 | tee -a "$ARQUIVO_LOG"
done
}

## TESTES DE BATERIA E CARREGAMENTO ##


test_battery_full() {
log "${PURPLE}=== TESTES DE BATERIA ==="

# Status completo
test_component "Status da bateria" termux-battery-status

# Carregamento
log "${CYAN}Verificando status de carregamento...${NC}"
termux-battery-status | jq '.plugged' | tee -a "$ARQUIVO_LOG"

# Saúde da bateria
log "${CYAN}Verificando saúde da bateria...${NC}"
termux-battery-status | jq '.health' | tee -a "$ARQUIVO_LOG"
}
## INFORMAÇÕES DO HARDWARE ##
get_hardware_info() {
log "${PURPLE}=== INFORMAÇÕES DE HARDWARE ==="

# Placa-mãe/SoC
log "${CYAN}Informações da plataforma:${NC}"
getprop ro.product.board | tee -a "$ARQUIVO_LOG"
getprop ro.board.platform | tee -a "$ARQUIVO_LOG"

# CPU
log "${CYAN}Informações da CPU:${NC}"
cat /proc/cpuinfo | grep -E 'model name|Hardware|Processor' | tee -a
"$ARQUIVO_LOG"

# Memória
log "${CYAN}Informações de memória:${NC}"
free -h | tee -a "$ARQUIVO_LOG"
cat /proc/meminfo | grep -E 'MemTotal|MemFree' | tee -a
"$ARQUIVO_LOG"

# Armazenamento
log "${CYAN}Informações de armazenamento:${NC}"
df -h | tee -a "$ARQUIVO_LOG"

# GPU
log "${CYAN}Informações da GPU:${NC}"
getprop ro.opengles.version | tee -a "$ARQUIVO_LOG"
dumpsys SurfaceFlinger | grep -i "GLES" | tee -a "$ARQUIVO_LOG"
}

### MENU PRINCIPAL ###


main_menu() {
clear
echo -e "${BLUE}=== TERMUX COMPLETE TEST SUITE ==="
echo -e "1. Testes completos do sistema"
echo -e "2. Testes de hardware avançado"
echo -e "3. Testes de tela"
echo -e "4. Testes de câmera avançados"
echo -e "5. Testes de áudio completo"
echo -e "6. Testes de conectividade"
echo -e "7. Testes de sensores"
echo -e "8. Testes de bateria"
echo -e "9. Informações de hardware"
echo -e "10. Todos os testes"
echo -e "0. Sair${NC}"

read -p "Selecione uma opção: " choice

case $choice in
1) run_system_tests ;;
2) run_hardware_tests ;;
3) test_screen ;;
4) test_camera_advanced ;;
5) test_audio_full ;;
6) test_connectivity_full ;;
7) test_sensors_full ;;
8) test_battery_full ;;
9) get_hardware_info ;;
10) run_all_tests ;;
0) exit 0 ;;
*) echo -e "${RED}Opção inválida${NC}"; sleep 1; main_menu ;;
esac

read -p "Pressione Enter para continuar..."


main_menu
}

run_system_tests() {
log "${BLUE}=== TESTES DO SISTEMA ==="
test_component "CPU" grep -i "model name" /proc/cpuinfo
test_component "Memória" free -h
test_component "Armazenamento" df -h
test_component "Kernel" uname -a
test_component "Processos" ps aux
}

run_hardware_tests() {
log "${BLUE}=== TESTES DE HARDWARE ==="
test_vibration
test_bluetooth
test_flashlight
test_airplane_mode
test_battery_saver
test_buttons
}

run_all_tests() {
run_system_tests
run_hardware_tests
test_screen
test_camera_advanced
test_audio_full
test_connectivity_full
test_sensors_full
test_battery_full
get_hardware_info
}

### INICIALIZAÇÃO ###


echo -e "${BLUE}=== TERMUX COMPLETE TEST SUITE ==="
echo -e "Versão 3.0 - Teste completo do dispositivo"
echo -e "Log sendo salvo em: ${YELLOW}$ARQUIVO_LOG${NC}"

main_menu
#!/bin/bash

# Configurações
ARQUIVO_LOG="termux_ultimate_test_$(date +%Y%m%d_%H%M%S).log"
QUARANTINE_DIR="$HOME/security_quarantine"
TEST_SERVER="google.com"
SPEEDTEST_SERVER="--server-id=2927"
WHITELIST=("termux" "com.termux" "com.android.shell")

# Cores para saída


RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
PURPLE='\033[0;35m'
NC='\033[0m'

# Criar diretórios necessários


mkdir -p "$QUARANTINE_DIR"

# Função para registrar resultados


log() {
echo -e "[$(date '+%H:%M:%S')] $1" | tee -a "$ARQUIVO_LOG"
}

# Função para testar componentes


test_component() {
local component_name="$1"
shift
log "${CYAN}Testando ${component_name}...${NC}"
if "$@" >> "$ARQUIVO_LOG" 2>&1; then
log "${GREEN} ${component_name} funcionando${NC}"
return 0
else
log "${RED} Falha no ${component_name}${NC}"
return 1
fi
}

### VERIFICAÇÃO DE DEPENDÊNCIAS ###


check_dependencies() {
local deps=("termux-api" "jq" "curl" "nmap" "git" "python" "rkhunter"
"clamav" "fdupes" "exiftool" "speedtest-cli" "procps" "htop"
"termux-tools" "net-tools" "dnsutils")
local missing=()

log "${BLUE}Verificando dependências...${NC}"


for dep in "${deps[@]}"; do
if ! command -v "$dep" &> /dev/null; then
missing+=("$dep")
fi
done

if [ ${#missing[@]} -gt 0 ]; then


log "${YELLOW}Instalando dependências faltantes...${NC}"
pkg install -y "${missing[@]}" || {
log "${RED}Falha ao instalar dependências${NC}";
return 1;
}
fi
}

### TESTES DE HARDWARE COMPLETO ###


test_hardware_full() {
log "${PURPLE}=== TESTES COMPLETOS DE HARDWARE ===${NC}"

# Informações básicas
test_component "CPU" lscpu || grep -i "model name" /proc/cpuinfo
test_component "Memória" free -h
test_component "Armazenamento" df -h

# Bateria
log "${CYAN}=== TESTE DE BATERIA ===${NC}"
termux-battery-status | tee -a "$ARQUIVO_LOG"

# Vibração
log "${CYAN}Testando vibração...${NC}"
for i in {100..500..100}; do
termux-vibrate -d $i
sleep 1
done

# Bluetooth
log "${CYAN}Testando Bluetooth...${NC}"
termux-bluetooth-status | tee -a "$ARQUIVO_LOG"
termux-bluetooth-devices | tee -a "$ARQUIVO_LOG"

# Lanterna
log "${CYAN}Testando lanterna...${NC}"
termux-torch on && sleep 2 && termux-torch off

# Modo Avião
log "${CYAN}Verificando modo avião...${NC}"
termux-airplane-mode | tee -a "$ARQUIVO_LOG"

# Modo Não Perturbe


log "${CYAN}Verificando modo não perturbe...${NC}"
termux-notification --action
"android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS" \
--title "Verifique manualmente" \
--content "Modo Não Perturbe deve ser verificado nas configurações do
sistema"
# Sensores
log "${CYAN}=== TESTES DE SENSORES ===${NC}"
termux-sensor -l | tee -a "$ARQUIVO_LOG"
for sensor in "accelerometer" "gyroscope" "light" "proximity"
"magnetic_field"; do
log "${CYAN}Testando sensor $sensor...${NC}"
termux-sensor -s $sensor -n 2 | tee -a "$ARQUIVO_LOG"
done

# Botões físicos (instruções)


log "${YELLOW}Para testar botões físicos (volume, power):"
log "1. Pressione cada botão"
log "2. Verifique a resposta do dispositivo${NC}"
}

### TESTES DE TELA ###


test_screen() {
log "${PURPLE}=== TESTES DE TELA ===${NC}"

# Brilho
log "${CYAN}Testando ajuste de brilho...${NC}"
for brightness in 50 100 150 200 255; do
termux-brightness $brightness
sleep 1
done
termux-brightness auto

# Cores
log "${CYAN}Testando cores da tela...${NC}"
for color in "red" "green" "blue" "white" "black"; do
termux-toast -b $color -c white -g top "Teste de cor: $color"
sleep 1
done

# Toque (instruções)
log "${YELLOW}Para testar touch screen:"
log "1. Execute um aplicativo de desenho"
log "2. Verifique a resposta em toda a área da tela${NC}"

# Pixels mortos (instruções)


log "${YELLOW}Para testar pixels mortos:"
log "1. Exiba telas com cores sólidas (preto, branco, vermelho, verde, azul)"
log "2. Verifique pontos que não mudam de cor${NC}"
}

### TESTES DE CÂMERA ###


test_camera() {
log "${PURPLE}=== TESTES DE CÂMERA ===${NC}"

# Câmera traseira
test_component "Câmera traseira" termux-camera-photo -c 0
rear_camera.jpg
[ -f rear_camera.jpg ] && {
log "${GREEN}Foto da câmera traseira salva em rear_camera.jpg${NC}"
exiftool rear_camera.jpg | grep -E 'Camera|Resolution' | tee -a
"$ARQUIVO_LOG"
rm rear_camera.jpg
}

# Câmera frontal
test_component "Câmera frontal" termux-camera-photo -c 1
front_camera.jpg
[ -f front_camera.jpg ] && {
log "${GREEN}Foto da câmera frontal salva em front_camera.jpg${NC}"
exiftool front_camera.jpg | grep -E 'Camera|Resolution' | tee -a
"$ARQUIVO_LOG"
rm front_camera.jpg
}

# Flash
log "${CYAN}Testando flash...${NC}"
termux-torch on && sleep 2 && termux-torch off
}

### TESTES DE ÁUDIO ###


test_audio() {
log "${PURPLE}=== TESTES DE ÁUDIO ===${NC}"

# Alto-falante
log "${CYAN}Testando alto-falante...${NC}"
termux-tts-speak "Teste do alto-falante do dispositivo" -r 1.2

# Microfone
test_component "Microfone" termux-microphone-record -f audio_test.aac -l
3
[ -f audio_test.aac ] && {
log "${GREEN}Gravação de áudio salva em audio_test.aac${NC}"
rm audio_test.aac
}

# Fone de ouvido (instruções)


log "${YELLOW}Para testar fone de ouvido:"
log "1. Conecte o fone"
log "2. Reproduza um áudio"
log "3. Verifique se o som sai no fone${NC}"
}

### TESTES DE REDE ###


test_network() {
log "${PURPLE}=== TESTES DE REDE ===${NC}"

# Ping
test_component "Ping básico" ping -c 4 "$TEST_SERVER"
log "${CYAN}Teste de ping avançado...${NC}"
ping -c 10 "$TEST_SERVER" | tee -a "$ARQUIVO_LOG" | grep -E
'rtt|packet loss'

# Velocidade
log "${CYAN}Testando velocidade da rede...${NC}"
speedtest-cli "$SPEEDTEST_SERVER" --simple | tee -a
"$ARQUIVO_LOG"

# Portas
test_component "Varredura de portas" nmap -Pn -T4 localhost

# DNS
test_component "Resolução DNS" dig "$TEST_SERVER" +short

# Wi-Fi
test_component "Conexão Wi-Fi" termux-wifi-connectioninfo

# GPS
test_component "GPS" termux-location

# Dados móveis
log "${CYAN}Verificando dados móveis...${NC}"
termux-telephony-cellinfo | tee -a "$ARQUIVO_LOG"
}

### TESTES DE SEGURANÇA ###


test_security() {
log "${PURPLE}=== TESTES DE SEGURANÇA ===${NC}"

# Rootkits
test_component "Verificação de rootkits" rkhunter --check --sk --quiet

# Vírus
test_component "Varredura de vírus" clamscan -r --bell -i "$HOME"

# Arquivos suspeitos
log "${CYAN}Buscando arquivos suspeitos...${NC}"
find /data /storage -type f \( -name "*.exe" -o -name "*.bat" -o -name "*.sh" \)
-exec ls -la {} + 2>/dev/null | tee -a "$ARQUIVO_LOG"

# Conexões suspeitas
log "${CYAN}Verificando conexões de rede...${NC}"
netstat -tuln | grep -E '(6667|2339|4444|5555|6666|1337|31337)' | tee -a
"$ARQUIVO_LOG"
}

### LIMPEZA E OTIMIZAÇÃO ###


clean_system() {
log "${PURPLE}=== LIMPEZA DO SISTEMA ===${NC}"

# Cache
test_component "Limpeza de cache" rm -rf ~/.cache/*
# Temporários
test_component "Limpeza de temporários" find /data /storage -name "*.tmp"
-delete 2>/dev/null

# RAM
test_component "Otimização de memória RAM" sync && echo 3 >
/proc/sys/vm/drop_caches

# Pacotes
test_component "Limpeza de pacotes" pkg autoclean

log "${GREEN}Limpeza do sistema concluída${NC}"


}

### INFORMAÇÕES DO SISTEMA ###


get_system_info() {
log "${PURPLE}=== INFORMAÇÕES DO SISTEMA ===${NC}"

# Hardware
log "${CYAN}=== HARDWARE ==="
log "Placa-mãe/SoC: $(getprop ro.product.board)"
log "Plataforma: $(getprop ro.board.platform)"
log "GPU: $(getprop ro.opengles.version)"
dumpsys SurfaceFlinger | grep -i "GLES" | tee -a "$ARQUIVO_LOG"

# Memória
log "${CYAN}=== MEMÓRIA ==="
free -h | tee -a "$ARQUIVO_LOG"
cat /proc/meminfo | grep -E 'MemTotal|MemFree' | tee -a
"$ARQUIVO_LOG"

# Armazenamento
log "${CYAN}=== ARMAZENAMENTO ==="
df -h | tee -a "$ARQUIVO_LOG"
log "Maiores arquivos:"
find /storage /data -type f -size +100M -exec du -h {} + 2>/dev/null | sort -rh |
head -n 10 | tee -a "$ARQUIVO_LOG"

# Sistema
log "${CYAN}=== SISTEMA ==="
log "Kernel: $(uname -a)"
log "Uptime: $(uptime)"
log "Processos ativos: $(ps aux | wc -l)"
}

### RELATÓRIO FINAL ###


generate_report() {
log "\n${PURPLE}=== RELATÓRIO FINAL ===${NC}"

local total_tests=$(grep -c "Testando" "$ARQUIVO_LOG")


local success_tests=$(grep -c "" "$ARQUIVO_LOG")
local failed_tests=$(grep -c "" "$ARQUIVO_LOG")

log "Total de testes realizados: $total_tests"


log "Testes bem-sucedidos: ${GREEN}$success_tests${NC}"
log "Testes com falha: ${RED}$failed_tests${NC}"

if [ "$failed_tests" -gt 0 ]; then


log "\n${RED}=== TESTES COM FALHA ===${NC}"
grep -B 1 "" "$ARQUIVO_LOG"
fi

log "\n${YELLOW}=== ALERTAS DE SEGURANÇA ===${NC}"


grep -iE "warning|error|suspeito|vírus|rootkit" "$ARQUIVO_LOG" | tail -n 10

log "\n${CYAN}=== DESEMPENHO ===${NC}"


grep -E "speed|download|upload|latency|memory|cpu" "$ARQUIVO_LOG" |
tail -n 15

log "\nLog completo disponível em: ${YELLOW}$ARQUIVO_LOG${NC}"


}

### MENU PRINCIPAL ###


main_menu() {
clear
echo -e "${BLUE}=== TERMUX ULTIMATE TEST SUITE ==="
echo -e "1. Testes completos do sistema"
echo -e "2. Testes de hardware"
echo -e "3. Testes de tela"
echo -e "4. Testes de câmera"
echo -e "5. Testes de áudio"
echo -e "6. Testes de rede"
echo -e "7. Testes de segurança"
echo -e "8. Informações do sistema"
echo -e "9. Limpeza do sistema"
echo -e "10. Todos os testes + limpeza"
echo -e "0. Sair${NC}"

read -p "Selecione uma opção: " choice

case $choice in
1) run_system_tests ;;
2) test_hardware_full ;;
3) test_screen ;;
4) test_camera ;;
5) test_audio ;;
6) test_network ;;
7) test_security ;;
8) get_system_info ;;
9) clean_system ;;
10) run_all_tests ;;
0) exit 0 ;;
*) echo -e "${RED}Opção inválida${NC}"; sleep 1; main_menu ;;
esac

read -p "Pressione Enter para continuar..."


main_menu
}

run_system_tests() {
test_hardware_full
test_screen
test_camera
test_audio
test_network
generate_report
}

run_all_tests() {
check_dependencies
run_system_tests
test_security
get_system_info
clean_system
generate_report
}

### INICIALIZAÇÃO ###


echo -e "${BLUE}=== TERMUX ULTIMATE TEST SUITE ==="
echo -e "Versão 3.5 - Teste completo do dispositivo"
echo -e "Log sendo salvo em: ${YELLOW}$ARQUIVO_LOG${NC}"

main_menu

Você também pode gostar