吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 9065|回复: 34
收起左侧

[Android 原创] xx软件库引流app软件分享弹窗制作脚本

  [复制链接]
jackghost 发表于 2020-8-11 09:11
看到这篇帖子去除软件分享弹窗以及引流弹窗教程想到帖子中提到的东西是两年前搞的,里面的按钮都是专门找人设计的,没想到今天出了这样一个教程贴,教大家怎么删除。
想想时间过得真快,有些东西放到手里也没啥用,放出来大家一起研究研究挺好。那这篇文章就分享下弹窗app的制作脚本吧。
提前声明下,代码可能有点乱,但应该是可以跑通的。对代码不做过多解释,大家有兴趣的自己研究研究改改,看的懂就看看,看不懂就算了。
附件中是模板文件,可以参考下。

脚本分3段,一段shell两段python
shell脚本
[Bash shell] 纯文本查看 复制代码
#!/bin/bash

#$1: 程序的文件夹
#$2: 包名


function begin()
{
	smali=$(findSmali $1)
	echo $smali
	echo '修改程序入口'
	interface=`python changeEnter.py $1/AndroidManifest.xml`
	inject $1 $smali $interface
	sign $1
}


function findSmali()
{

	smali=''

	if [ ! -d $1/smali_classes3 ];then
		if [ ! -d ./$1/smali_classes2 ];then
			smali='smali_classes2'
		else
			smali='smali_classes3'
		fi
	else
		smali='smali_classes4'
	fi

	if [ ! -d "$1/$smali" ];then
		mkdir $1/$smali
	fi

	echo $smali

	# return $smali
}

# $1 注入程序文件夹
# $2 注入程序smali文件位置
# $3 程序入口文件
function inject()
{
	echo '开始注入代码'

	if [ ! -d "$1/res/drawable" ];then
		mkdir $1/res/drawable
	fi

	if [ ! -d "$1/res/layout" ];then
		mkdir $1/res/layout
	fi

	cp ./template/*.png ./$1/res/drawable
	cp ./template/color_cursor.xml ./$1/res/drawable

	cp ./template/activity_card.xml ./$1/res/layout

	if [ ! -d "$1/$2/com" ];then
		mkdir $1/$2/com
	fi

	if [ ! -f "$1/res/values/ids.xml" ]; then
		touch $1/res/values/ids.xml
		echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<resources>
</resources>"  >> $1/res/values/ids.xml
	fi

	echo "$1/res/values/colors.xml"
	if [ ! -f "./$1/res/values/colors.xml" ]; then
		touch $1/res/values/colors.xml
		echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<resources>
</resources>" >> $1/res/values/colors.xml
	fi

	if [ ! -f "$1/res/values/styles.xml" ]; then
		touch $1/res/values/styles.xml
		echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<resources>
</resources>" >> $1/res/values/styles.xml
	fi

	cp -r ./template/cutils ./$1/$2/com/

	python editxml.py ./$1/res/values/ ./$1/$2/com/cutils/


	sed -i "" "s#CMainInterfaceActivity#$3#g"  ./$1/$2/com/cutils/FActivity.smali
	# sed -i "" "s#CMainInterfaceActivity#$3#g"  ./$1/$2/com/cutils/CActivity\$OnShareListener.smali


	echo '注入代码成功'
}

#
function sign()
{
	echo '开始打包并安装'

	apktool b $1

	rm -rf $1/build

	mv $1/dist/$1.apk $1"_unsign.apk"

	rm -rf $1/dist

	jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA -keystore ./DaoKey.jks -storepass 密码1 -keypass 密码2 -signedjar $1.apk $1"_unsign.apk" Dao

}


apktool d $1.apk

begin $1

sign $1

rm -rf $2

rm -f $2"_unsign.apk"

rm -f $1$2.apk

mv $2".apk" $1

# sed -i "" "s#My/XuanAo/BaZiYi/#com/bby/BaZi/#g" *.smali


第二段 python: 修改apk的入口文件:
[Python] 纯文本查看 复制代码
# -*- coding: utf-8 -*-  
import sys
import os
import xmltodict
import collections



def change_interface(src):
	with open(src,'r+') as file:
		xml = file.read()
		doc = xmltodict.parse(xml)
		
		old_name = ''
		old_note = collections.OrderedDict()

		if isinstance(doc['manifest']['application']['activity'],dict):
				note = doc['manifest']['application']['activity']
				if isinstance(note['intent-filter'],list):
					isinterface = is_interface_from_list(note['intent-filter'])
					if isinterface:
						old_name = note['@android:name']

				else:
					isinterface = is_interface_from_dict(note['intent-filter'])
					if isinterface:
						old_name = note['@android:name']
		else:
			for note in doc['manifest']['application']['activity']:
				if note.has_key('intent-filter'):
					if isinstance(note['intent-filter'],list):
						isinterface = is_interface_from_list(note['intent-filter'])
						if isinterface:
							old_name = note['@android:name']

					elif isinstance(note['intent-filter'],dict):
						isinterface = is_interface_from_dict(note['intent-filter'])
						if isinterface:
							old_name = note['@android:name']


		activity = collections.OrderedDict()
		category = collections.OrderedDict()
		action = collections.OrderedDict()
		intent = collections.OrderedDict()
		
		activity['@android:name'] = 'com.cutils.CActivity'
		activity['@android:theme'] = '@style/CShareAppTheme'
		category['@android:name'] = 'android.intent.category.LAUNCHER'
		action['@android:name'] = 'android.intent.action.MAIN'

		intent['action'] = action
		intent['category'] = category
		activity['intent-filter'] = intent

		if isinstance(doc['manifest']['application']['activity'],list):
			doc['manifest']['application']['activity'].insert(0,activity)
		else:
			signal = doc['manifest']['application']['activity']
			activityList = [signal,activity];
			doc['manifest']['application']['activity'] = activityList

		# doc['manifest']['application']['activity'].insert(0,activity)

		with open('./manifest_tmp.xml','w') as f:
			f.writelines(xmltodict.unparse(doc))
		return old_name


def is_interface_from_list(notes):
	for note in notes:
		if note.has_key('category') and isinstance(note['category'],list):
			category = note['category']
			for item in category:
				if item['@android:name'].find('category.LAUNCHER') > 0:
					category.remove(item)
					return True
		elif note.has_key('category') and isinstance(note['category'],dict):
			if note['category']['@android:name'].find('category.LAUNCHER') > 0:
				del note['category']
				return True

	return False

def is_interface_from_dict(note):
	if note.has_key('category') and isinstance(note['category'],list):
		category = note['category']
		for item in category:
			if item['@android:name'].find('category.LAUNCHER') > 0:
				category.remove(item)
				return True
	elif note.has_key('category') and isinstance(note['category'],dict):
		if note['category']['@android:name'].find('category.LAUNCHER') > 0:
			del note['category']
			return True
	else:
		return False
			


if __name__ == '__main__':
	reload(sys)
	sys.setdefaultencoding('utf-8')
	src = sys.argv[1]
	old_interface = change_interface(src)
	cmd = 'xmllint --format ./manifest_tmp.xml' + ' > ' +src
	# cmd = 'xmllint --format ./manifest_tmp.xml > test.xml'
	os.system(cmd)
	print(old_interface.replace('.','\/'))



第三段 修改apk资源包中的一些属性文件
[Python] 纯文本查看 复制代码
# -*- coding: utf-8 -*-  
import sys
import os
import xmltodict


def insertitem(src,des):
	try:
		fsrc = open(src,'r')
		linessrc = fsrc.readlines()

		fdes = open(des,'r+')
		linesdes = fdes.readlines()

		for line in linessrc:
			linesdes.insert(-1,line)


		fdes.seek(0)
		fdes.truncate()
		fdes.writelines(linesdes)

		fsrc.close()
		fdes.close()

	except Exception as e:
		raise e

def insertxml(src,des):
	try:
		fsrc = open(src,'r')
		linessrc = fsrc.readlines()
		del linessrc[0]
		del linessrc[0]
		del linessrc[-1]

		fdes = open(des,'r+')
		linesdes = fdes.readlines()

		for line in linessrc:
			linesdes.insert(-1,line)


		fdes.seek(0)
		fdes.truncate()
		fdes.writelines(linesdes)

		fsrc.close()
		fdes.close()

	except Exception as e:
		raise e


def getvalues(src):
	with open (src,'r') as file:
		xml = file.read()
		doc = xmltodict.parse(xml)
		dic = {'id':0,'color':0,'layout':0,'drawable':0,'style':0}

		for note in doc['resources']['public']:
			if note['@type'] == 'id' and note['@id'] > dic['id']:
				dic['id'] = note['@id']
			if note['@type'] == 'color' and note['@id'] > dic['color']:
				dic['color'] = note['@id']
			if note['@type'] == 'layout' and note['@id'] > dic['layout']:
				dic['layout'] = note['@id']
			if note['@type'] == 'drawable' and note['@id'] > dic['drawable']:
				dic['drawable'] = note['@id']
			if note['@type'] == 'style' and note['@id'] > dic['style']:
				dic['style'] = note['@id']

		return dic

def setvalues(src,base):
	with open(src,'r+') as file:
		xml = file.read()
		doc = xmltodict.parse(xml)
		i = 1
		if base['id'] == 0:
			base['id'] = '0x7f090000'
		if base['color'] == 0:
			base['color'] = '0x7f060000'

		if base['layout'] == 0:
			base['layout'] = '0x7f0b0000'

		if base['drawable'] == 0:
			base['drawable'] = '0x7f080000'

		if base['style'] == 0:
			base['style'] = '0x7f100000'

		for note in doc['resources']['public']:
			if note['@type'] == 'id':
				note['@id'] = hex(int(base['id'],16) + i)
			if note['@type'] == 'color':
				note['@id']= hex(int(base['color'],16) + i)
			if note['@type'] == 'layout':
				note['@id']= hex(int(base['layout'],16) + i)
			if note['@type'] == 'drawable':
				note['@id']= hex(int(base['drawable'],16) + i)
			if note['@type'] == 'style':
				note['@id']= hex(int(base['style'],16) + i)
			i = i + 1

		file.seek(0)
		file.truncate()
		file.writelines(xmltodict.unparse(doc))

		return doc


if __name__ == '__main__':

	des = sys.argv[1]
	desc = sys.argv[2]

	insertitem('./template/ids.xml', des + 'ids.xml')
	insertitem('./template/colors.xml', des + 'colors.xml')
	insertitem('./template/style.xml', des + 'styles.xml')

	base = getvalues(des + 'public.xml')
	doc = setvalues('./template//public.xml',base)

	os.system('xmllint --format ./template/public.xml > ./tmp.xml')

	insertxml('tmp.xml',des + 'public.xml')
	for note in doc['resources']['public']:
		cmd = "sed -i \"\" \"s/" + note['@name'] + '/' + note['@id'] + '/g\" ' + desc +'CActivity.smali'
		os.system(cmd)

	os.system('rm -f tmp.xml')


最后:
如果点赞多的话后面把后台的源码也开源出来大家一起玩玩。
最后提醒大家不要干坏事

template.zip

998.73 KB, 下载次数: 214, 下载积分: 吾爱币 -1 CB

模板文件

免费评分

参与人数 15吾爱币 +11 热心值 +14 收起 理由
myxszjb + 1 + 1 我很赞同!
辉光日新K88 + 1 热心回复!
evildoer7758 + 1 我很赞同!
shangdidejiupin + 1 + 1 鼓励转贴优秀软件安全工具和文档!
dreamlivemeng + 1 + 1 用心讨论,共获提升!
542044545 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
Charlie_ + 1 + 1 我很赞同!
19183311119 + 1 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
绝对的孤独者 + 1 热心回复!
一只别豪猪 + 1 鼓励转贴优秀软件安全工具和文档!
silence2540 + 1 + 1 热心回复!
eoven8 + 1 + 1 热心回复!
heixiazi + 1 + 1 热心回复!
ludoux + 1 用心讨论,共获提升!
那年夏天52 + 2 + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

yha 发表于 2020-8-11 09:17
感谢大佬!
绫音 发表于 2020-8-11 09:25
cl173339545 发表于 2020-8-11 09:27
涛之雨 发表于 2020-8-11 09:34
清羽弹窗。搜一下就有
baisepikaq 发表于 2020-8-11 09:41
感谢分享代码
 楼主| jackghost 发表于 2020-8-11 09:46
本帖最后由 jackghost 于 2020-8-11 09:49 编辑
涛之雨 发表于 2020-8-11 09:34
清羽弹窗。搜一下就有

那个没太注意过
ludoux 发表于 2020-8-11 09:49
感谢大佬,十分厉害了
Hea7en 发表于 2020-8-11 10:10
学习一下   
Linshengqiang 发表于 2020-8-11 10:21
楼主技术不错哦
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-7 21:11

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表