Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
buihien224 authored Dec 4, 2023
1 parent 3069fa2 commit f476fa5
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 18 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name: miuivs_patch_build
on:
workflow_dispatch:
inputs:
S:
description: 'Services.jar Url'
required: true
default: ''
F:
description: 'Framework.jar Url'
required: true
Expand Down
28 changes: 14 additions & 14 deletions bhlnk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
dir=$(pwd)
repM="python3 $dir/bin/strRep.py"

get_file_dir() {
if [[ $1 ]]; then
if [[ $2 == "auto" ]]; then
sudo find $dir/img_temp/ -name $1
elif [[ $2 ]]; then
sudo find $dir/$2/ -name $1 | head -1
else
sudo find $dir/img_temp/ -name $1 | head -1
fi
else
return 0
fi
}

jar_util()
{
cd $dir
Expand Down Expand Up @@ -72,19 +86,6 @@ jar_util()
fi
}

services() {

jar_util d "services.jar" fw

#repM isSecureLocked false WindowState.smali
#repM onPostNotification void AlertWindowNotification.smali

repM 'isPlatformSigned' true 'PackageManagerService$PackageManagerInternalImpl.smali'
repM 'isSignedWithPlatformKey' true 'PackageImpl.smali'

jar_util a "services.jar" fw
}


framework() {

Expand All @@ -111,7 +112,6 @@ if [[ ! -d $dir/jar_temp ]]; then

fi

services
framework


Expand Down
115 changes: 115 additions & 0 deletions bin/strRep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import sys
from configobj import ConfigObj

# Functions
# Author : @trungmmmmt

def Linecounter(phrase, source, isText=0, startsAt=0):
result = []
if isText:
if isText == 1 or isText == True:
source = source.splitlines()
for (i, line) in enumerate(source):
if i >= startsAt:
if phrase in line :
result.append(i)
return result
else:
with open(source, 'r') as f:
return Linecounter(phrase, f, 2, startsAt)
return False

def lineNumByPhrase(phrase, source, isText=0, startsAt=0):
if isText:
if isText == 1 or isText == True:
source = source.splitlines()
for (i, line) in enumerate(source):
if i >= startsAt:
if phrase in line :
return i
else:
with open(source, 'r') as f:
return lineNumByPhrase(phrase, f, 2, startsAt)
return False


def fileReplaceRange(filename, startIndex, endIndex, content):
if startIndex:
lines = []
with open(filename, 'r') as f:
lines = f.readlines()

with open(filename, 'w') as f:
wrote = False
for i, line in enumerate(lines):
if i not in range(startIndex, endIndex + 1):
f.write(line)
else:
if not wrote:
f.write(content + '\n')
wrote = True

def count_parameters(method_signature):
parameter_list = method_signature.split('(')[1].split(')')[0].split(';')
parameter_list = list(filter(lambda x: x != '', parameter_list))
parameter_count = len(parameter_list)
return parameter_count


def process_input(func,input_value):
if isinstance(input_value, int):
hex_value = hex(input_value)
return func.replace("X1", str(input_value))

def print_line(file_path, line_number):
with open(file_path, 'r') as file:
lines = file.readlines()
if line_number <= len(lines):
line = lines[line_number - 1]
return line.strip()

# Main script
# Loading configs


true="""
.locals 1
const v0, 0x1
return v0
"""

false="""
.locals 1
const v0, 0x0
return v0
"""


if str(sys.argv[2]) == "true":
replaceWith = true
else :
replaceWith = false

replaceFile = str(sys.argv[3])
phraseStart = " " + str(sys.argv[1]) + "("
phraseEnd = '.end method'

if len(sys.argv) - 1 > 0:
counter = Linecounter(phraseStart, replaceFile)
temp=0
for linez in counter:
startIndex = lineNumByPhrase(phraseStart, replaceFile, 0, temp) + 1
endIndex = lineNumByPhrase(phraseEnd, replaceFile, 0, (startIndex -1 )) -1

if str(sys.argv[2]) == "drm":
reg = print_line(replaceFile, startIndex)
replaceWith = process_input(drm, count_parameters(reg))

fileReplaceRange(replaceFile, startIndex, endIndex, replaceWith)
temp = startIndex


0 comments on commit f476fa5

Please sign in to comment.