本次使用的工具有:

TinyProxyNox 模拟器

配置TinyProxy

TinyProxy安装请参照: https://www.ym68.cc/linux/2020/001074.html

编辑/etc/tinyproxy/tinyproxy.conf配置文件并写入如下信息

User tinyproxy
Group tinyproxy
Port 8888
Timeout 600
DefaultErrorFile "/usr/share/tinyproxy/default.html"
StatFile "/usr/share/tinyproxy/stats.html"
LogFile "/var/log/tinyproxy/tinyproxy.log"
LogLevel Connect
PidFile "/var/run/tinyproxy/tinyproxy.pid"
MaxClients 100
MinSpareServers 5
MaxSpareServers 20
StartServers 10
MaxRequestsPerChild 0
ViaProxyName "tinyproxy"
DisableViaHeader Yes
ConnectPort 443

修改完成配置文件后重启tinyproxy服务

[root@cloud-master ~]# systemctl restart tinyproxy

安装Nox模拟器

Nox模拟器下载链接:https://file.api.ym68.cc/exe/tools/nox_setup_v6.6.0.5_full_intl.exe

安装Nox模拟器后,点击桌面Tools->设置->WLAN 长按Wifi名称配置代理信息

下载Sugar(苏格)APP并进行安装:https://apk.sugarcdn.cn/sugar.apk

正常登陆后可根据需要配置操作录制,此处不演示。

查看/var/log/tinyproxy/tinyproxy.log日志信息

以下为脚本内容:

#!/bin/bash
#Sugar抓包日志处理并下载 By:admin@ym68.cc
#指定目录
Sugar_Path='/data/sugar'
Sugar_Log_Path="${Sugar_Path}/logs"
#历史文件,需提前创建空文件或已有文件
Sugar_All_Log_Path="${Sugar_Log_Path}/Sugar_Image_History.log"
Sugar_New_Log_Path="${1}"
Sugar_Image_Path="${Sugar_Path}/image"
Sugar_All_Log_Code=`cat ${Sugar_All_Log_Path}`
Sugar_New_Log_Code=`cat ${Sugar_New_Log_Path}|sed -n 's/.*\(http.*\.jpg\).*/\1/p'|sort|uniq |egrep -v 'alias|icon|video_thumb|img.sugarapp.cn'`
mkdir -p ${Sugar_Log_Path} ${Sugar_Image_Path}
for Sugar_Image_Code in ${Sugar_New_Log_Code}
do
	Image_Down_Name=`echo "${Sugar_Image_Code}"|sed -n 's#.*sugarapp\.cn/.*/\(.*\)/.*/\(.*\.jpg\)#\1_\2#p'`
	if [[ ! "${Sugar_All_Log_Code}" =~ "${Sugar_Image_Code}" ]];then
		Down_Info=`wget -q -t 5 -bO "${Sugar_Image_Path}/${Image_Down_Name}" "${Sugar_Image_Code}"`
		if [[ "${Down_Info}" =~ "Continuing" ]];then
			echo -e "\033[32m当前正下载${Image_Down_Name}中~\033[0m"
		#else
		#	echo -e "\033[31m任务${Image_Down_Name}下载失败~\033[0m"
		#	echo "${Sugar_Image_Code}" >> /tmp/
		fi
		sed -i "\$a${Sugar_Image_Code}" ${Sugar_All_Log_Path}
	#else
	#	echo -e "\033[31m${Image_Down_Name}已存在~\033[0m"
	fi
done
Md5_Info=`md5sum ${Sugar_Image_Path}/* `
Repeat_Code=`echo "${Md5_Info}" |awk '{print $1}' |sort |uniq -d`
for File_Md5 in ${Repeat_Code};do
	File_Repeat_List=`echo "${Md5_Info}" |awk "/${File_Md5}/ {print \\$0}" |awk 'NR>1 {print $2}'`
	#删除重复文件
	Read_Num=`echo "${File_Repeat_List}" |wc -l`
	echo -e "\033[32m当前共重复${Read_Num}个文件~\033[0m"
	rm -f ${File_Repeat_List}
done
cd ${Sugar_Image_Path}
tar zcf "Sugar_Image_All_$(date '+2020%m%d').tar.gz" *.jpg
rm -f *.jpg

执行格式为:

bash Sugar.sh log日志地址

需要的目录为:/data/sugar,/data/sugar/logs,/data/sugar/image

[root@Frpd-vip bin]# bash Sugar.sh ../logs/tinyproxy.log

默认图片下载至:/data/sugar/image目录下,脚本执行完成后会打包tar.gz包


该文章采用「CC 协议」,转载必须注明作者和本文链接.
分类: Linux