Advertisement
arter97

Untitled

Aug 27th, 2016
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. TMP=tmp.$(date +%s)$(uuidgen | sed s/-//g)
  4. apktool d -o $TMP "$@"
  5. VERSION=$(cat $TMP/apktool.yml | grep versionName: | awk '{print $2}')
  6. cd $TMP
  7. find . -name '*.smali' -exec grep "Landroid/os/Build;->MANUFACTURER:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
  8.     findstr "Landroid/os/Build;->MANUFACTURER:Ljava/lang/String;" | while read file; do
  9.         sed -i -e "s@sget-object $sed Landroid/os/Build;->MANUFACTURER:Ljava/lang/String;@const-string $sed \"samsung\"@g" $file
  10.     done
  11. done
  12. find . -name '*.smali' -exec grep "Landroid/os/Build;->DEVICE:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
  13.     findstr "Landroid/os/Build;->DEVICE:Ljava/lang/String;" | while read file; do
  14.         sed -i -e "s@sget-object $sed Landroid/os/Build;->DEVICE:Ljava/lang/String;@const-string $sed \"zeroflte\"@g" $file
  15.     done
  16. done
  17. find . -name '*.smali' -exec grep "Landroid/os/Build;->MODEL:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
  18.     findstr "Landroid/os/Build;->MODEL:Ljava/lang/String;" | while read file; do
  19.         sed -i -e "s@sget-object $sed Landroid/os/Build;->MODEL:Ljava/lang/String;@const-string $sed \"SM-G920F\"@g" $file
  20.     done
  21. done
  22. find . -name '*.smali' -exec grep "Landroid/os/Build;->HARDWARE:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
  23.     findstr "Landroid/os/Build;->HARDWARE:Ljava/lang/String;" | while read file; do
  24.         sed -i -e "s@sget-object $sed Landroid/os/Build;->HARDWARE:Ljava/lang/String;@const-string $sed \"samsungexynos7420\"@g" $file
  25.     done
  26. done
  27.  
  28.  
  29. AD_CREATOR=$(grep -l ".field final A" \
  30.            $(grep -l ".field public static final CREATOR" \
  31.            $(find smali* -type f -exec \
  32.              grep -l ".method public constructor <init>(Ljava/util/List;" {} +)))
  33. if echo $AD_CREATOR | grep -q " "; then
  34.     # Multiple classes detected, bail out
  35.     echo "Multiple AD_CREATOR classes detected!"
  36.     echo $AD_CREATOR
  37.     exit 1
  38. fi
  39. echo -n "AD_CREATOR detected : "
  40. echo $AD_CREATOR
  41.  
  42. AD_CREATOR_LINE=$(grep -n ".method public constructor <init>(Ljava/util/List;" $AD_CREATOR | cut -f1 -d:)
  43. sed -i "$((${AD_CREATOR_LINE} + 2))i\    .param p1" $AD_CREATOR
  44. if ! sed -n "${AD_CREATOR_LINE},$((${AD_CREATOR_LINE} + 10))p" $AD_CREATOR | grep -q "invoke-direct {p0}, Ljava/lang/Object;-><init>()V"; then
  45.     # "invoke-direct {p0}, Ljava/lang/Object;-><init>()V" not found
  46.     echo "invoke-direct {p0}, Ljava/lang/Object;-><init>()V not found!"
  47.     exit 1
  48. fi
  49.  
  50. sed -i "${AD_CREATOR_LINE},$((${AD_CREATOR_LINE} + 10))s/invoke-direct {p0}, Ljava\/lang\/Object;-><init>()V/invoke-direct {p0}, Ljava\/lang\/Object;-><init>()V\n    invoke-static {}, Ljava\/util\/Collections;->emptyList()Ljava\/util\/List;\n    move-result-object p1/" $AD_CREATOR
  51.  
  52. echo "$AD_CREATOR patched!"
  53.  
  54.  
  55. AD_EXT=$(find smali* -type f -exec \
  56.              grep -l "/VAST/Ad/Wrapper/Extensions/Extension" {} +)
  57. if echo $AD_EXT | grep -q " "; then
  58.     # Multiple classes detected, bail out
  59.     echo "Multiple AD_EXT classes detected!"
  60.     echo $AD_EXT
  61.     exit 1
  62. fi
  63. echo -n "AD_EXT detected : "
  64. echo $AD_EXT
  65.  
  66. AD_EXT_TEXT=$(cat $AD_EXT | grep ".method public static")
  67. AD_EXT_LINE=$(grep -n ".method public static" $AD_EXT | cut -f1 -d:)
  68. sed -i '/.method public static/,/.end method/ d' $AD_EXT
  69. sed -i "${AD_EXT_LINE}i\\${AD_EXT_TEXT}\n    .locals 3\n    .prologue\n    return-void\n.end method" $AD_EXT
  70.  
  71. echo "$AD_EXT patched!"
  72.  
  73. echo "Patching XMLs"
  74. echo "watch_metadata_cards
  75. inline_ad_overlay
  76. default_ad_overlay
  77. embedded_ad_overlay
  78. mdx_ad_overlay
  79. promoted_video_item
  80. q_promoted_video_item
  81. compact_promoted_video_item
  82. generic_promo_banner
  83. promoted_app_install
  84. compact_promoted_item
  85. interstitial_promo_view
  86. promoted_tall_descriptive_banner
  87. promoted_short_descriptive_banner
  88. grid_promoted_banner
  89. music_key_promo_banner
  90. music_key_promo_feature_item
  91. music_key_promo_small_feature_item
  92. promoted_app_install_right_align_layout
  93. sign_in_promo
  94. promoted_text_banner_layout_one
  95. promoted_text_banner_layout_two
  96. promoted_text_banner_layout_three
  97. music_key_promo_feature_item_text
  98. generic_promo_card
  99. background_promo
  100. promoted_app_install_new_line_layout
  101. invideo_programming_overlay
  102. info_cards_teaser_overlay" | while read to_find; do find res -name ${to_find}*.xml; done | while read file; do
  103. echo "android:layout_height=
  104. android:layout_margin=
  105. android:layout_marginBottom=
  106. android:layout_marginEnd=
  107. android:layout_marginLeft=
  108. android:layout_marginRight=
  109. android:layout_marginStart=
  110. android:layout_marginTop=
  111. android:layout_width=" | while read text; do cat $file | tr ' ' '\n' | sed -e 's/</ /g' -e 's/>/ /g' -e 's/ //g' | grep $text | while read grepped; do
  112. sed -i -e "s#$grepped#${text}\"0.0dip\"#g" $file; done; done; done
  113.  
  114. cp -rp res tmp
  115. cd tmp
  116. # set to false
  117. echo "show_startup_promo
  118. enable_channel_layer_banner
  119. generic_promo_banner_view" | while read bool; do find . -name bools.xml -exec grep -l $bool {} + | while read file; do sed -i -e "s#$(cat ../res/$file | grep $bool)#$(cat ../res/$file | grep $bool | sed -e s/true/false/g)#g" $file; done; done
  120. # set to true
  121. echo "supports_rtl" | while read bool; do find . -name bools.xml -exec grep -l $bool {} + | while read file; do sed -i -e "s#$(cat ../res/$file | grep $bool)#$(cat ../res/$file | grep $bool | sed -e s/false/true/g)#g" $file; done; done
  122. cd ..
  123. rm -rf res
  124. mv tmp res
  125. echo "XMLs patched!"
  126.  
  127. apktool b -c -a /home/arter97/arter97/bin/aapt
  128. mv dist/* ../$TMP.zip
  129. cd ..
  130. zipalign -v 4 $TMP.zip YouTube-${VERSION}_SM-G920F.apk
  131. rm -rf $TMP $TMP.zip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement