• Need help getting Windows to list all files inside every APK and then look for advertising SDKs

    From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 20:02:36 2026
    From Newsgroup: alt.comp.os.windows-10

    Yesterday, the chain of events was such that:
    1. Stefan Ram posted a warning that Android APKs can leak location
    Message-ID: <locations-20260805220107@ram.dialup.fu-berlin.de>
    2. I then showed how use Win10 to determine if any apps leaked recently
    Message-ID: <1150g5v$1lsp$1@nnrp.usenet.blueworldhosting.com>
    3. But I then spent hours trying to confirm if any of my APKs "can" leak

    A. Windows can tell you if a device "has" leaked in the past time frame
    B. And, Windows can tell you if a device "can" leak in the future...

    But...
    I just can't, for the life of me, get the batch commands to work!
    Of course, the sequence has to work for every package on the system.

    But we have no idea what packages are on the system.
    adb shell pm list packages -f

    So, for now, for debug and test, let's assume there is only one package.
    <com.wemagineai.voila>

    So I run the commands on that one package as my simplest test case.
    adb shell pm list packages -f | findstr /i com.wemagineai.voila

    That means our starting point will be a thousand lines like this one line:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    What we want to do is get Windows batch to be able to give us:
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    Then, we can "unzip -list" to spit out all the files inside the APK.
    adb shell unzip -l "/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk"

    At that point, we can search the listed APK contents for ad SDK patterns
    findstr /i /g:scanads_patterns.txt those_contents.txt

    Where the pattern file is the following ad-related SDKs
    com/facebook/ads/AdManager
    com/mopub/mobileads
    com/applovin/mediation
    com/unity3d/ads/android
    com/ironsource/mediationsdk
    com/bytedance/sdk/openads
    com/chartboost/sdk
    com/inmobi/ads
    com/vungle/publisher
    com/mintegral/msdk
    com/tapjoy/TJAdUnit
    com/adcolony/sdk
    com/amazon/device/ads/AdRegistration

    And if we find any of them, we report it to the user
    a. the APK name
    b. the ad sdk(s) found

    The step I'm having trouble with is this:
    #1: We will have a thousand lines, like this one:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    What we need to do is get Windows batch to be able to give us:
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    How?
    --
    1. Stefan Ram posted a warning that Android APKs can leak location
    From: Stefan Ram <ram@zedat.fu-berlin.de>
    Newsgroups: comp.mobile.android
    Subject: Many ad SDKs share locations
    Date: 5 Aug 2026 21:06:00 GMT
    Message-ID: <locations-20260805220107@ram.dialup.fu-berlin.de>

    2. I then showed how I determined none of my APKs actually did that
    Newsgroups: comp.mobile.android
    Subject: PSA: A quick Android location and network access audit using adb
    Date: Wed, 5 Aug 2026 15:15:11 -0800
    Message-ID: <1150g5v$1lsp$1@nnrp.usenet.blueworldhosting.com >
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 12:22:20 2026
    From Newsgroup: alt.comp.os.windows-10

    Maria Sophia wrote:
    #1: We will have a thousand lines, like this one:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    What we need to do is get Windows batch to be able to give us:
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    How?

    Specifically, how do we turn this:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila
    Into this (without knowing the name of the package ahead of time)
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    To be clear, the Windows batch problem I'm running into is:
    a. Windows CMD cannot seem to split on multi-character delimiters.
    b. So Windows CMD cannot therefore split on /base.apk.
    c. Windows CMD cannot seem to split on slash (/) either.
    d. Windows CMD cannot split on the package name (because it's unknown).
    e. Windows CMD cannot split on any character that appears inside the path.
    f. Including the equal sign (=) which appears in sequence sometimes (==).

    For example, this doesn't work, even from the command line o/s of batch.

    1. Spit out all packages (but testing with one)
    adb shell pm list packages -f | findstr /i com.wemagineai.voila > voila_1packages_raw.txt

    Inspect results
    type voila_1packages_raw.txt
    Actual Output = Expected Output
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    2. Remove the 'package:' prefix, but keep the rest
    for /f "tokens=2 delims=:" %A in (voila_1packages_raw.txt) do echo %A > voila_after_package.txt

    Inspect results
    type voila_after_package.txt
    Actual Output = Expected Output
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    3. Extract everything up to /base.apk (the step I am stuck on!)
    for /f "tokens=1 delims==" %A in (voila_after_package.txt) do echo %A > voila_apkpath.txt

    Inspect results
    type voila_apkpath.txt
    Actual Output does not = Expected Output

    This is the desired output:
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk
    This is the actual output:
    /data/app/~~0H1-2NstdUVjAZffiA36og

    That's just one of (oh, I can't count how many) parsing attempts I made.

    In desperation, here's a summary of the problem, in a nutshell:
    a. I can't figure out how to turn a thousand lines like this:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    b. Into this (without knowing the name of the package ahead of time)
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    c. Can you?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 12:26:39 2026
    From Newsgroup: alt.comp.os.windows-10

    Maria Sophia wrote:
    In desperation, here's a summary of the problem, in a nutshell:
    a. I can't figure out how to turn a thousand lines like this:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    b. Into this (without knowing the name of the package ahead of time)
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    c. Can you?

    Just for the record, if parsing doesn't work on the command line,
    then it won't work in batch either... (as that's even harder).

    But... to give you an idea of the final goal, here it is.

    :: ------------------------------------------------------------------
    :: Note Windows thinks Android /data is a Windows path!
    :: The failure is inside CMD's batch parser.
    :: ------------------------------------------------------------------
    :: scanads.bat
    :: Scans non-rooted Android 10+ to look inside all apps for ad SDKs
    :: 1. connects to Android via ADB on the Windows desktop
    :: 2. lists installed apps on the Android device
    :: 3. extracts APK paths for each Android app on the device
    :: 4. runs unzip -l on each APK to list all the files inside each app
    :: 5. searches for known ad SDK classpaths <== this is failing in batch!
    :: 6. counts apps containing the known specific ad SDKs
    :: 7. prints a summary of APKs found that have specific ad-related SDKs
    :: ------------------------------------------------------------------
    :: Debug: scanads.bat > full_console_output.txt 2>&1
    :: cmd /v /c "echo on & call scanads.bat > full_trace.txt 2>&1"
    :: One issue is CMD's parsing of paths beginning with /.
    :: ------------------------------------------------------------------
    :: v2p1 20260806 debugging because I can't get Windows parsing to work!
    :: v2p0 20260806 Created scanads_patterns.txt file containing SDKs
    :: Because these strings only appear in apps that actually embed ad SDKs.
    :: com/facebook/ads/AdManager
    :: com/mopub/mobileads
    :: com/applovin/mediation
    :: com/unity3d/ads/android
    :: com/ironsource/mediationsdk
    :: com/bytedance/sdk/openads
    :: com/chartboost/sdk
    :: com/inmobi/ads
    :: com/vungle/publisher
    :: com/mintegral/msdk
    :: com/tapjoy/TJAdUnit
    :: com/adcolony/sdk
    :: com/amazon/device/ads/AdRegistration
    :: v1p9 20260806 added "setlocal enabledelayedexpansion"
    :: v1p8 20260805 List APKs with ad SDKs in the summary and into a file
    :: v1p7 20260805 Cleaned up minor errors and strengthened the summary
    :: v1p6 20260805 Changed to match SDK classpaths, not metadata filenames
    :: v1p5 20260805 Tightened grep from "ads" to a list of known ad packages
    :: v1p4 20260805 Added result summary for packages found with ad SDKs
    :: v1p3 20260805 Set temporary file names via easily-modified variables
    :: v1p2 20260805 Added separate output folder and consistent file names
    :: v1p1 20260805 Added checks to make sure adb is working first
    :: v1p0 20260805 Scans all Android apps for ad-related packages
    :: ------------------------------------------------------------------
    :: This program connects to an Android device over ADB, collects the
    :: full list of installed apps, extracts the file paths of their APKs,
    :: and then scans each APK for known ad-network SDKs. For every APK,
    :: it uses unzip -l on the device to list all files inside the package,
    :: then it searches that file list for specific SDK classpaths. If any
    :: of those classpaths appear, the app is counted as containing an ad SDK.
    :: Otherwise, the app is counted as clean. At the end, the script prints
    :: a summary showing how many APKs were scanned, how many contained ad SDKs,
    :: and how many did not. Here is my first output on my daily drive:
    :: Total APKs scanned: 986
    :: APKs containing ad-related files: 3
    :: APKs with no ad-related files: 983
    :: ------------------------------------------------------------------
    @echo off
    setlocal enabledelayedexpansion
    echo Android APK Ad Network Scanner
    echo.

    REM Working directory and filenames and counters
    :: Define the directory name for temp working files
    set WORKDIR=scanads
    :: Define the file name for the list of package names and APK paths
    set RAWPKG=%WORKDIR%\scanads_1packages_raw.txt
    :: Define the file name for the list of APKs scanned
    set APKPATHS=%WORKDIR%\scanads_2apkpaths.txt
    :: Define the file name for the APK unzip showing every file in the APK
    set APKCONTENTS=%WORKDIR%\scanads_3apkcontents.tmp
    :: Define the ephemeral file name for ad-SDK classpath matches
    set MATCHES=%WORKDIR%\scanads_4matches.tmp
    :: Define the file where we save all APKs that contain ad SDKs
    set ADSOUT=%WORKDIR%\scanads_5adsfound.txt
    :: Define a pattern file that contains the desired search keywords
    set PATTERNS=scanads_patterns.txt
    :: Start counters at zero
    set COUNT_TOTAL=0
    set COUNT_ADS=0
    set COUNT_NOADS=0

    REM Create working directory if missing
    if not exist %WORKDIR% mkdir %WORKDIR%

    REM Check ADB connection
    adb get-state > nul 2>&1
    if errorlevel 1 (
    echo No device detected. Connect Android and enable USB debugging.
    exit /b
    )

    REM Check unzip availability
    adb shell which unzip > nul 2>&1
    if errorlevel 1 (
    echo Device does not have unzip. Install BusyBox or enable unzip.
    exit /b
    )

    REM Dump package list
    echo Pulling package list...
    adb shell pm list packages -f > %RAWPKG%
    echo Package list saved.
    echo.

    REM Extract APK paths
    echo Extracting APK paths...
    powershell -NoLogo -NoProfile -Command "(Get-Content '%RAWPKG%' | ForEach-Object { ($_ -replace '^package:','') -replace '=[^=]+$','' }) | Set-Content '%APKPATHS%'"

    echo APK paths saved.
    echo.

    REM Scan APKs
    echo Scanning for ad networks...
    echo.

    :: v1p8: clear output file for ad-SDK results
    echo Ad SDKs found in these APKs: > "%ADSOUT%"

    :: begin scan loop
    for /f "usebackq delims=" %%A in ("%APKPATHS%") do (
    set /a COUNT_TOTAL+=1
    echo Scanning %%A

    :: v1p8: clear APKCONTENTS before unzip to avoid stale data
    echo. > "%APKCONTENTS%"
    adb shell unzip -l "%%A" > "%APKCONTENTS%" 2>nul

    :: v1p8: clear MATCHES to avoid stale data
    echo. > "%MATCHES%"

    :: Find ad SDKs inside of the list of files in every APK
    :: findstr /i "com/facebook/ads/AdManager com/mopub/mobileads com/applovin/mediation com/unity3d/ads/android com/ironsource/mediationsdk com/bytedance/sdk/openads com/chartboost/sdk com/inmobi/ads com/vungle/publisher com/mintegral/msdk com/tapjoy/TJAdUnit com/adcolony/sdk com/amazon/device/ads/AdRegistration" %APKCONTENTS% > %MATCHES%

    findstr /i /g:"%PATTERNS%" "%APKCONTENTS%" > "%MATCHES%"

    :: errorlevel=0 means matches found, therefore it has ads
    :: errorlevel=1 means no matches, therefore it does not have ads
    if errorlevel 1 (
    set /a COUNT_NOADS+=1
    del %MATCHES% 2>nul
    ) else (
    echo [ADS] %%A
    for /f %%X in (%MATCHES%) do echo %%X

    :: v1p8: append results to ADSOUT file
    echo APK: %%A >> "%ADSOUT%"
    for /f %%X in (%MATCHES%) do echo %%X >> "%ADSOUT%"
    echo. >> "%ADSOUT%"

    set /a COUNT_ADS+=1

    :: Save it for debugging
    copy "%MATCHES%" "scanads\matches_%%~nA.tmp" >nul

    del %MATCHES% 2>nul
    )
    )
    :: end scan loop

    echo.
    echo Scan complete.

    echo.
    echo Summary:
    echo Total APKs scanned: %COUNT_TOTAL%
    echo APKs containing ad-related files: %COUNT_ADS%
    echo APKs with no ad-related files: %COUNT_NOADS%
    echo.

    :: v1p8 show the file containing detailed ad-SDK results
    echo Detailed list saved to: %ADSOUT%
    echo.

    gvim %ADSOUT%
    pause

    :: end of scanads.bat
    --
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 20:28:44 2026
    From Newsgroup: alt.comp.os.windows-10

    Maria Sophia <mariasophia@comprehension.com> wrote or quoted:
    To be clear, the Windows batch problem I'm running into is:

    Not sure if I got the problem right. But this example batch
    here strips the initial "package:" and the final "= . . .":

    @ECHO OFF
    SETLOCAL enabledelayedexpansion

    SET "mystring=package:mykey=myvalue=extradata"

    IF /i "!mystring:~0,8!"=="package:" (
    SET "mystring=!mystring:~8!"
    )

    :LOOP
    IF "!mystring:~-1!"=="=" (
    SET "mystring=!mystring:~0,-1!"
    GOTO :DONE
    )
    SET "mystring=!mystring:~0,-1!"
    IF NOT "!mystring!"=="" GOTO :LOOP

    :DONE
    ECHO Result: %mystring%
    @REM Result: mykey=myvalue
    PAUSE

    However, it has not been tested for all edge cases.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 12:40:58 2026
    From Newsgroup: alt.comp.os.windows-10

    Stefan Ram wrote:
    Maria Sophia <mariasophia@comprehension.com> wrote or quoted:
    To be clear, the Windows batch problem I'm running into is:

    Not sure if I got the problem right. But this example batch
    here strips the initial "package:" and the final "= . . .":

    @ECHO OFF
    SETLOCAL enabledelayedexpansion

    SET "mystring=package:mykey=myvalue=extradata"

    IF /i "!mystring:~0,8!"=="package:" (
    SET "mystring=!mystring:~8!"
    )

    :LOOP
    IF "!mystring:~-1!"=="=" (
    SET "mystring=!mystring:~0,-1!"
    GOTO :DONE
    )
    SET "mystring=!mystring:~0,-1!"
    IF NOT "!mystring!"=="" GOTO :LOOP

    :DONE
    ECHO Result: %mystring%
    @REM Result: mykey=myvalue
    PAUSE

    However, it has not been tested for all edge cases.

    Hi Stefan,

    It's all your fault. :)
    You started this! :)

    *(I'm saying that accusation in a nice way!)*

    When you posted a warning that ad-related SDKs secretly embedded in common
    apps sell our location to brokers without our knowledge, I immediately used Windows to see if any of my Android apps gave away my location recently.

    At the time, I wrote this to help others run the same tests that I did.

    Note that the tests below only tell you whether your location was
    compromised in the past. It doesn't tell you if it "can" be compromised.

    That's what the scanads.bat file is supposed to do.
    But for the record, here's how to tell if you "have" been compromised.

    1. List dangerous permissions, grouped by category
    adb shell pm list permissions -g -d | findstr /i location
    => permission:android.permission.ACCESS_FINE_LOCATION
    => permission:android.permission.ACCESS_COARSE_LOCATION
    => permission:android.permission.ACCESS_BACKGROUND_LOCATION
    => permission:android.permission.ACCESS_MEDIA_LOCATION
    => group:android.permission-group.LOCATION

    2. List all apps that currently have location permission granted
    adb shell cmd location get-app-ops | findstr /i allowed
    => returns nothing
    This means no apps currently have AppOps-level location access logged.
    But it does not mean no apps have permission as permissions
    can be granted at any time (some are granted by the system even!).

    3. List every app that has ever registered for location
    adb shell dumpsys appops | findstr /i "fine coarse gps"
    => No app shows recent location access timestamps.

    4. Identify which apps have actually used location recently
    adb shell dumpsys appops --op COARSE_LOCATION
    adb shell dumpsys appops --op FINE_LOCATION
    adb shell dumpsys appops --op GPS

    Note:
    COARSE_LOCATION -> network-based location
    FINE_LOCATION -> GNSS + high-accuracy location
    GPS -> direct GNSS hardware access

    Results:
    These timestamps show past location accesses, sometimes years old.
    Only a few system components show activity within the last days.
    Shows no evidence of 3rd-party apps performing recent location access.

    5. Real-time monitoring of apps accessing location
    adb shell dumpsys appops | findstr /i location
    adb shell dumpsys appops | findstr /i "fine coarse gps"

    The output contains
    COARSE_LOCATION entries
    FINE_LOCATION entries
    ACCESS_MEDIA_LOCATION entries
    GPS / WIFI_SCAN / MONITOR_LOCATION entries
    A huge number of system services accessing location
    Several mock location apps (fake GPS apps)
    Many Samsung system components
    Many Google Play Services location providers

    The phone has many apps that can utilize location, such as
    Google Play Services
    Samsung location services
    multiple mock GPS apps
    GPS logging apps
    compass apps
    wildfire location apps
    location sharing apps
    GPS alarm apps
    GPS test apps
    GPS waypoint apps
    sun/moon time apps
    various GPS utilities

    6. Identify which apps have accessed location in the last 24 hours
    adb shell dumpsys appops --history
    Syntax note:
    Access: <timestamp> <uid> <package> <mode> <state>
    Reject: <timestamp> <uid> <package> <mode> <state>

    Results:
    No entries show access within the last 24 hours.
    No installed application accessed location in the last 24 hours.
    No advertising SDK accessed location in the last 24 hours.
    No hidden or unknown apps accessed location in the last 24 hours.
    Only system components show historical access and even then,
    all timestamps are older than 24 hours.
    This confirms that no location leak occurred in the last 24 hours.

    7. Live network activity monitoring (per app)
    adb shell while true; do date; netstat -an; sleep 1; done

    This shows
    Stable long-lived TCP to Google Play services:
    Stable long-lived carrier/IPsec VPN tunnels:
    Stable long-lived ADB/scrcpy over TCP/IPv6:
    But no obvious new or rapidly changing connections:

    8. Look at each TCP socket, one per line:
    adb shell cat /proc/net/tcp
    => sl local_address rem_address st ... uid ...
    => 0: 040000C0:8578 BC4CD9AC:146C ... uid 0
    => 1: 0401A8C0:9D30 BC73FA8E:146C ... uid 10321
    => 2: 0401A8C0:BB38 BC65FA8E:146C ... uid 0

    The two "uid 0" connections are root / kernel / system services.
    But one connection belongs to UID 10321

    UID 10321 means:
    a. One of the installed apps (not the system)
    b. currently has an active TCP connection
    c. to a remote server (the hex IP BC73FA8E)
    d. This is the only user-level app connection in the snapshot.
    But we do not yet know which app it is but we can identify it.

    9. Identify the app owning UID 10321
    adb shell ps -A | findstr 10321
    => Drat. Reports nothing

    adb shell cmd package list packages --uid 10218
    => package:com.google.android.gsf uid:10218
    => package:com.google.android.gms uid:10218

    adb shell cmd package list packages --uid 10321
    => package:eu.faircode.netguard uid:10321

    Results:
    Only Google Services Framework, Google Play Services & Netguard,
    have UIDs that appear in the network socket snapshots.

    10. Summary of which apps have accessed network sockets in the last 24
    hours
    In the last 24 hours, the only applications that accessed network
    sockets were:
    System processes (UID 0)
    Google Play Services / Google Services Framework (UID 10218)
    NetGuard firewall (UID 10321)

    No other installed applications accessed network sockets.

    Hence, only system components, Google Play Services, and NetGuard
    show any network or location activity, with no evidence of access
    by any other apps.

    Now, to look at your suggestion, I'll take that up in the next post.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann 'Myrkraverk' Oskarsson@johann@myrkraverk.invalid to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Fri Aug 7 04:52:40 2026
    From Newsgroup: alt.comp.os.windows-10

    On 07/08/2026 4:26 AM, Maria Sophia wrote:
    Maria Sophia wrote:
    In desperation, here's a summary of the problem, in a nutshell:
    a. I can't figure out how to turn a thousand lines like this:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    b. Into this (without knowing the name of the package ahead of time)
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    c. Can you?

    Just for the record, if parsing doesn't work on the command line,
    then it won't work in batch either... (as that's even harder).



    Dear Maria Sophia,

    Do you need to do this in a batch file? For all kinds of scripting
    tasks, my battleground of choice is the Lua programming language.

    If this only needs to run on your own computer, that's a viable
    option, but does necessitate a new battle for you: to learn Lua.

    I tend to build my own Lua interpreter from the sources, and I'm
    sure you can find viable binaries elsewhere, should you seek this
    adventure.

    For the specifics of the batch processing, I have no more to add
    that hasn't already been said by other wizards of the Windows
    arcana.


    Happy victories over syntax errors!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 13:07:10 2026
    From Newsgroup: alt.comp.os.windows-10

    Stefan Ram wrote:
    @ECHO OFF
    SETLOCAL enabledelayedexpansion

    SET "mystring=package:mykey=myvalue=extradata"

    IF /i "!mystring:~0,8!"=="package:" (
    SET "mystring=!mystring:~8!"
    )

    :LOOP
    IF "!mystring:~-1!"=="=" (
    SET "mystring=!mystring:~0,-1!"
    GOTO :DONE
    )
    SET "mystring=!mystring:~0,-1!"
    IF NOT "!mystring!"=="" GOTO :LOOP

    :DONE
    ECHO Result: %mystring%
    @REM Result: mykey=myvalue
    PAUSE


    Hi Stefan,

    Let's work with what you suggested, as the goal is to turn a thousand lines like this for the Google Play Store into a path to base.apk for grepping.

    Note: I realized Voila cartoonify is not on everyone's Android, so I
    changed the example to the Google Play Store which is likely on many.

    1. Obtain one of a thousand packages raw information:
    adb shell pm list packages -f | findstr /i com.android.vending > gp_1packages_raw.txt
    type gp_1packages_raw.txt
    package:/data/app/~~qyBhv8SiMEVDVGgpxCgj4A==/com.android.vending-zsgN1Nq3SLXMf0JnL1AcrA==/base.apk=com.android.vending

    2. Remove the package prefix but keep the rest:
    for /f "tokens=2 delims=:" %A in (gp_1packages_raw.txt) do echo %A > gp_after_package.txt
    type gp_after_package.txt
    /data/app/~~qyBhv8SiMEVDVGgpxCgj4A==/com.android.vending-zsgN1Nq3SLXMf0JnL1AcrA==/base.apk=com.android.vending

    3. Remove everything after base.apk if possible
    for /f "tokens=1 delims==" %A in (gp_after_package.txt) do echo %A > gp_apkpath.txt
    type gp_apkpath.txt

    Expected: /data/app/~~qyBhv8SiMEVDVGgpxCgj4A==/com.android.vending-zsgN1Nq3SLXMf0JnL1AcrA==/base.apk
    Actual: /data/app/~~qyBhv8SiMEVDVGgpxCgj4A

    Now let's look at your suggested batch code for starters, which does this:
    a. remove "package:"
    b. loop backwards until the last character is =
    c. remove that =
    d. stop and echo the result
    This is an interesting approach, given all my efforts failed so far.

    So let's try it for the Google Play Store <com.android.vending> package.

    A. Read the line from the previous file
    set /p mystring=<gp_1packages_raw.txt
    B. Remove the 'package:' prefix .
    if /i "!mystring:~0,8!"=="package:" (
    set "mystring=!mystring:~8!"
    )
    C. Strip everything after the last =
    :LOOP
    if "!mystring:~-1!"=="=" (
    set "mystring=!mystring:~0,-1!"
    goto :DONE
    )
    set "mystring=!mystring:~0,-1!"
    if not "!mystring!"=="" goto :LOOP
    D. Output the APK path
    :DONE
    echo Result: !mystring!

    Let's test it.

    Step 1.
    adb shell pm list packages -f | findstr /i com.android.vending > gp_1packages_raw.txt
    type gp_1packages_raw.txt
    package:/data/app/~~qyBhv8SiMEVDVGgpxCgj4A==/com.android.vending-zsgN1Nq3SLXMf0JnL1AcrA==/base.apk=com.android.vending

    Step 2.
    gvim stefan.bat
    @ECHO OFF
    SETLOCAL ENABLEDELAYEDEXPANSION

    REM Load the real line from your file
    set /p mystring=<gp_1packages_raw.txt

    REM Strip "package:" prefix
    IF /i "!mystring:~0,8!"=="package:" (
    SET "mystring=!mystring:~8!"
    )

    :LOOP
    REM Stop when last char is "="
    IF "!mystring:~-1!"=="=" (
    SET "mystring=!mystring:~0,-1!"
    GOTO :DONE
    )

    REM Chop one character from the end
    SET "mystring=!mystring:~0,-1!"
    IF NOT "!mystring!"=="" GOTO :LOOP

    :DONE
    ECHO Result: !mystring!
    PAUSE

    Step 3. Run the parser Stefan so kindly provided.
    stefan.bat
    Result: /data/app/~~qyBhv8SiMEVDVGgpxCgj4A==/com.android.vending-zsgN1Nq3SLXMf0JnL1AcrA==/base.apk
    Press any key to continue . . .

    Voila! It worked!. I wish I knew this 24 hours ago!
    Thanks. I'll incorporate it into the script to scan for all
    APKs on the system, list their contents, and look for Ad SDKs.

    Note that can be used to look for anything but the original
    goal is to find all the ad sdks on our system that "can" trigger.
    --
    Usenet is where you can often find people who know much more than you do.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 13:27:39 2026
    From Newsgroup: alt.comp.os.windows-10

    Maria Sophia wrote:
    Thanks. I'll incorporate it into the script to scan for all
    APKs on the system, list their contents, and look for Ad SDKs.

    Note that can be used to look for anything but the original
    goal is to find all the ad sdks on our system that "can" trigger.


    This is getting closer... but it's not quite there yet... as I had
    to make it a subroutine but I'm still getting errors...

    It will eventually work.
    Here's the current status... It doesn't throw syntax errors.

    But it ends with

    ... billions of lines...
    The system cannot find the drive specified.
    The system cannot find the drive specified.
    Scanning /system/priv-app/SecSoundPicker/SecSoundPicker.apk
    The system cannot find the drive specified.
    The system cannot find the drive specified.
    Scanning /data/app/~~tzuj3WurSpKFVmnllqWMWw==/com.pixlr.removebg-e9DUGN4gtU8pMabH2172hQ==/base.apk
    The system cannot find the drive specified.
    The system cannot find the drive specified.

    Scan complete.

    Summary:
    Total APKs scanned: 986
    APKs containing ad-related files: 3
    APKs with no ad-related files: 983

    Detailed list saved to: scanads\scanads_5adsfound.txt

    ECHO is off.

    :: ------------------------------------------------------------------
    :: scanads.bat
    :: Scans non-rooted Android 10+ to look inside all apps for ad SDKs
    :: 1. connects to Android via ADB on the Windows desktop
    :: 2. lists installed apps on the Android device
    :: 3. extracts APK paths for each Android app on the device
    :: (this is the step I needed help on from the Usenet newsgroups)
    :: 4. runs unzip -l on each APK to list all the files inside each app
    :: 5. searches for known ad SDK classpaths
    :: 6. counts apps containing the known specific ad SDKs
    :: 7. prints a summary of APKs found that have specific ad-related SDKs
    :: ------------------------------------------------------------------
    :: Debug: scanads.bat > full_console_output.txt 2>&1
    :: cmd /v /c "echo on & call scanads.bat > full_trace.txt 2>&1"
    :: ------------------------------------------------------------------
    :: v2p3 20260806 Had to move the trimming logic OUTSIDE the parentheses
    :: because: for (...) do (...) blocks cannot contain :labels
    :: becasue: goto cannot jump into or out of a parenthesized block
    :: therefore: the trimming loop must be a subroutine
    :: v2p2 20260806 Replaced extract APK powershell with Stefan's suggestion
    :: v2p1 20260806 debugging galore (with help from Stefan Ram on Usenet)
    :: v2p0 20260806 Created scanads_patterns.txt file containing SDKs
    :: Because these strings only appear in apps that actually embed ad SDKs.
    :: com/facebook/ads/AdManager
    :: com/mopub/mobileads
    :: com/applovin/mediation
    :: com/unity3d/ads/android
    :: com/ironsource/mediationsdk
    :: com/bytedance/sdk/openads
    :: com/chartboost/sdk
    :: com/inmobi/ads
    :: com/vungle/publisher
    :: com/mintegral/msdk
    :: com/tapjoy/TJAdUnit
    :: com/adcolony/sdk
    :: com/amazon/device/ads/AdRegistration
    :: v1p9 20260806 added "setlocal enabledelayedexpansion"
    :: v1p8 20260805 List APKs with ad SDKs in the summary and into a file
    :: v1p7 20260805 Cleaned up minor errors and strengthened the summary
    :: v1p6 20260805 Changed to match SDK classpaths, not metadata filenames
    :: v1p5 20260805 Tightened grep from "ads" to a list of known ad packages
    :: v1p4 20260805 Added result summary for packages found with ad SDKs
    :: v1p3 20260805 Set temporary file names via easily-modified variables
    :: v1p2 20260805 Added separate output folder and consistent file names
    :: v1p1 20260805 Added checks to make sure adb is working first
    :: v1p0 20260805 Scans all Android apps for ad-related packages
    :: ------------------------------------------------------------------
    :: This program connects to an Android device over ADB, collects the
    :: full list of installed apps, extracts the file paths of their APKs,
    :: and then scans each APK for known ad-network SDKs. For every APK,
    :: it uses unzip -l on the device to list all files inside the package,
    :: then it searches that file list for specific SDK classpaths. If any
    :: of those classpaths appear, the app is counted as containing an ad SDK.
    :: Otherwise, the app is counted as clean. At the end, the script prints
    :: a summary showing how many APKs were scanned, how many contained ad SDKs,
    :: and how many did not. Here is my first output on my daily drive:
    :: Total APKs scanned: 986
    :: APKs containing ad-related files: 3
    :: APKs with no ad-related files: 983
    :: ------------------------------------------------------------------
    @echo off
    setlocal enabledelayedexpansion
    echo Android APK Ad Network Scanner
    echo.

    REM Working directory and filenames and counters
    :: Define the directory name for temp working files
    set WORKDIR=scanads
    :: Define the file name for the list of package names and APK paths
    set RAWPKG=%WORKDIR%\scanads_1packages_raw.txt
    :: Define the file name for the list of APKs scanned
    set APKPATHS=%WORKDIR%\scanads_2apkpaths.txt
    :: Define the file name for the APK unzip showing every file in the APK
    set APKCONTENTS=%WORKDIR%\scanads_3apkcontents.tmp
    :: Define the ephemeral file name for ad-SDK classpath matches
    set MATCHES=%WORKDIR%\scanads_4matches.tmp
    :: Define the file where we save all APKs that contain ad SDKs
    set ADSOUT=%WORKDIR%\scanads_5adsfound.txt
    :: Define a pattern file that contains the desired search keywords
    set PATTERNS=scanads_patterns.txt
    :: Start counters at zero
    set COUNT_TOTAL=0
    set COUNT_ADS=0
    set COUNT_NOADS=0

    REM Create working directory if missing
    if not exist %WORKDIR% mkdir %WORKDIR%

    REM Check ADB connection
    adb get-state > nul 2>&1
    if errorlevel 1 (
    echo No device detected. Connect Android and enable USB debugging.
    exit /b
    )

    REM Check unzip availability
    adb shell which unzip > nul 2>&1
    if errorlevel 1 (
    echo Device does not have unzip. Install BusyBox or enable unzip.
    exit /b
    )

    REM Dump package list
    echo Pulling package list...
    adb shell pm list packages -f > %RAWPKG%
    echo Package list saved.
    echo.

    REM Extract APK paths (v2p3 pure batch version)
    echo Extracting APK paths...

    > "%APKPATHS%" (
    for /f "usebackq delims=" %%L in ("%RAWPKG%") do (
    call :ExtractPath "%%L"
    )
    )

    echo APK paths saved.
    echo.


    echo APK paths saved.
    echo.

    REM Scan APKs
    echo Scanning for ad networks...
    echo.

    :: v1p8: clear output file for ad-SDK results
    echo Ad SDKs found in these APKs: > "%ADSOUT%"

    :: begin scan loop
    for /f "usebackq delims=" %%A in ("%APKPATHS%") do (
    set /a COUNT_TOTAL+=1
    echo Scanning %%A

    :: v1p8: clear APKCONTENTS before unzip to avoid stale data
    echo. > "%APKCONTENTS%"
    adb shell unzip -l "%%A" > "%APKCONTENTS%" 2>nul

    :: v1p8: clear MATCHES to avoid stale data
    echo. > "%MATCHES%"

    :: Find ad SDKs inside of the list of files in every APK
    :: findstr /i "com/facebook/ads/AdManager com/mopub/mobileads com/applovin/mediation com/unity3d/ads/android com/ironsource/mediationsdk com/bytedance/sdk/openads com/chartboost/sdk com/inmobi/ads com/vungle/publisher com/mintegral/msdk com/tapjoy/TJAdUnit com/adcolony/sdk com/amazon/device/ads/AdRegistration" %APKCONTENTS% > %MATCHES%

    findstr /i /g:"%PATTERNS%" "%APKCONTENTS%" > "%MATCHES%"

    :: errorlevel=0 means matches found, therefore it has ads
    :: errorlevel=1 means no matches, therefore it does not have ads
    if errorlevel 1 (
    set /a COUNT_NOADS+=1
    del %MATCHES% 2>nul
    ) else (
    echo [ADS] %%A
    for /f %%X in (%MATCHES%) do echo %%X

    :: v1p8: append results to ADSOUT file
    echo APK: %%A >> "%ADSOUT%"
    for /f %%X in (%MATCHES%) do echo %%X >> "%ADSOUT%"
    echo. >> "%ADSOUT%"

    set /a COUNT_ADS+=1

    :: Save it for debugging
    copy "%MATCHES%" "scanads\matches_%%~nA.tmp" >nul

    del %MATCHES% 2>nul
    )
    )
    :: end scan loop

    echo.
    echo Scan complete.

    echo.
    echo Summary:
    echo Total APKs scanned: %COUNT_TOTAL%
    echo APKs containing ad-related files: %COUNT_ADS%
    echo APKs with no ad-related files: %COUNT_NOADS%
    echo.

    :: v1p8 show the file containing detailed ad-SDK results
    echo Detailed list saved to: %ADSOUT%
    echo.

    REM Subroutine: ExtractPath
    REM Input: %1 = raw line from pm list packages -f
    REM Output: trimmed APK path (echoed)
    :ExtractPath
    setlocal enabledelayedexpansion

    set "line=%~1"

    REM Strip leading "package:"
    if /i "!line:~0,8!"=="package:" (
    set "line=!line:~8!"
    )

    REM Trim everything after the last "="
    set "tmp=!line!"
    :trimloop
    if "!tmp:~-1!"=="=" (
    set "tmp=!tmp:~0,-1!"
    goto :trimdone
    )
    set "tmp=!tmp:~0,-1!"
    if not "!tmp!"=="" goto :trimloop

    :trimdone
    echo !tmp!
    endlocal
    goto :eof

    gvim %ADSOUT%
    pause

    :: end of scanads.bat
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 21:32:19 2026
    From Newsgroup: alt.comp.os.windows-10

    Maria Sophia <mariasophia@comprehension.com> wrote or quoted:
    The system cannot find the drive specified.

    You can remove the

    @echo off

    to get more context about where this message is coming from.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Thu Aug 6 13:55:47 2026
    From Newsgroup: alt.comp.os.windows-10

    Stefan Ram wrote:
    You can remove the

    @echo off

    to get more context about where this message is coming from.

    Thanks Stefan, as this should run on anyone's Windows box with Android.
    My Android is connected over Wi-Fi via the adb connect script.

    I just saw this, so I'll just post my latest version, but it's still
    saying "The system cannot find the drive specified" for some reason.


    :: ------------------------------------------------------------------
    :: scanads.bat
    :: Scans non-rooted Android 10+ to look inside all apps for ad SDKs
    :: 1. connects to Android via ADB on the Windows desktop
    :: 2. lists installed apps on the Android device
    :: 3. extracts APK paths for each Android app on the device
    :: (this is the failing step)
    :: 4. runs unzip -l on each APK to list all the files inside each app
    :: 5. searches for known ad SDK classpaths
    :: 6. counts apps containing the known specific ad SDKs
    :: 7. prints a summary of APKs found that have specific ad-related SDKs
    :: ------------------------------------------------------------------
    :: Debug: scanads.bat > full_console_output.txt 2>&1
    :: cmd /v /c "echo on & call scanads.bat > full_trace.txt 2>&1"
    :: Clue: The system cannot find the drive specified.
    :: ------------------------------------------------------------------
    :: v2p4 20260806 Had to force Windows to rewrite files with CRLF line endings
    :: because Android uses LF but Windows expects CRLF instead
    :: Had to move the subroutine as cmd interpreted lables wrong
    :: v2p3 20260806 Had to move the trimming logic OUTSIDE the parentheses
    :: because: for (...) do (...) blocks cannot contain :labels
    :: and: goto cannot jump into or out of a parenthesized block
    :: therefore: the trimming loop must be a subroutine
    :: v2p2 20260806 Replaced extract APK powershell with Stefan's suggestion
    :: v2p1 20260806 debugging galore (with help from Stefan Ram on Usenet)
    :: v2p0 20260806 Created scanads_patterns.txt file containing SDKs
    :: Because these strings only appear in apps that actually embed ad SDKs.
    :: com/facebook/ads/AdManager
    :: com/mopub/mobileads
    :: com/applovin/mediation
    :: com/unity3d/ads/android
    :: com/ironsource/mediationsdk
    :: com/bytedance/sdk/openads
    :: com/chartboost/sdk
    :: com/inmobi/ads
    :: com/vungle/publisher
    :: com/mintegral/msdk
    :: com/tapjoy/TJAdUnit
    :: com/adcolony/sdk
    :: com/amazon/device/ads/AdRegistration
    :: v1p9 20260806 added "setlocal enabledelayedexpansion"
    :: v1p8 20260805 List APKs with ad SDKs in the summary and into a file
    :: v1p7 20260805 Cleaned up minor errors and strengthened the summary
    :: v1p6 20260805 Changed to match SDK classpaths, not metadata filenames
    :: v1p5 20260805 Tightened grep from "ads" to a list of known ad packages
    :: v1p4 20260805 Added result summary for packages found with ad SDKs
    :: v1p3 20260805 Set temporary file names via easily-modified variables
    :: v1p2 20260805 Added separate output folder and consistent file names
    :: v1p1 20260805 Added checks to make sure adb is working first
    :: v1p0 20260805 Scans all Android apps for ad-related packages
    :: ------------------------------------------------------------------
    :: This program connects to an Android device over ADB, collects the
    :: full list of installed apps, extracts the file paths of their APKs,
    :: and then scans each APK for known ad-network SDKs. For every APK,
    :: it uses unzip -l on the device to list all files inside the package,
    :: then it searches that file list for specific SDK classpaths. If any
    :: of those classpaths appear, the app is counted as containing an ad SDK.
    :: Otherwise, the app is counted as clean. At the end, the script prints
    :: a summary showing how many APKs were scanned, how many contained ad SDKs,
    :: and how many did not. Here is my first output on my daily drive:
    :: Total APKs scanned: 986
    :: APKs containing ad-related files: 3
    :: APKs with no ad-related files: 983
    :: ------------------------------------------------------------------
    @echo off
    setlocal enabledelayedexpansion
    echo Android APK Ad Network Scanner
    echo.

    REM Working directory and filenames and counters
    :: Define the directory name for temp working files
    set WORKDIR=scanads
    :: Define the file name for the list of package names and APK paths
    set RAWPKG=%WORKDIR%\scanads_1packages_raw.txt
    :: Define the file name for the list of APKs scanned
    set APKPATHS=%WORKDIR%\scanads_2apkpaths.txt
    :: Define the file name for the APK unzip showing every file in the APK
    set APKCONTENTS=%WORKDIR%\scanads_3apkcontents.tmp
    :: Define the ephemeral file name for ad-SDK classpath matches
    set MATCHES=%WORKDIR%\scanads_4matches.tmp
    :: Define the file where we save all APKs that contain ad SDKs
    set ADSOUT=%WORKDIR%\scanads_5adsfound.txt
    :: Define a pattern file that contains the desired search keywords
    set PATTERNS=scanads_patterns.txt
    :: Start counters at zero
    set COUNT_TOTAL=0
    set COUNT_ADS=0
    set COUNT_NOADS=0

    REM Create working directory if missing
    if not exist %WORKDIR% mkdir %WORKDIR%

    REM Check ADB connection
    adb get-state > nul 2>&1
    if errorlevel 1 (
    echo No device detected. Connect Android and enable USB debugging.
    exit /b
    )

    REM Check unzip availability
    adb shell which unzip > nul 2>&1
    if errorlevel 1 (
    echo Device does not have unzip. Install BusyBox or enable unzip.
    exit /b
    )

    REM Dump package list
    echo Pulling package list...
    adb shell pm list packages -f > %RAWPKG%
    :: Need to convert Android LF into Windows CRLF
    powershell -NoLogo -NoProfile -Command "(Get-Content '%RAWPKG%') | Set-Content '%RAWPKG%'"
    echo Package list saved.
    echo.

    REM Extract APK paths (v2p3 pure batch version)
    echo Extracting APK paths...

    > "%APKPATHS%" (
    for /f "usebackq delims=" %%L in ("%RAWPKG%") do (
    call :ExtractPath "%%L"
    )
    )

    echo APK paths saved.
    echo.


    echo APK paths saved.
    echo.

    REM Scan APKs
    echo Scanning for ad networks...
    echo.

    :: v1p8: clear output file for ad-SDK results
    echo Ad SDKs found in these APKs: > "%ADSOUT%"

    :: begin scan loop
    for /f "usebackq delims=" %%A in ("%APKPATHS%") do (
    set /a COUNT_TOTAL+=1
    echo Scanning %%A

    :: v1p8: clear APKCONTENTS before unzip to avoid stale data
    echo. > "%APKCONTENTS%"
    adb shell unzip -l "%%A" > "%APKCONTENTS%" 2>nul

    :: v1p8: clear MATCHES to avoid stale data
    echo. > "%MATCHES%"

    :: Find ad SDKs inside of the list of files in every APK
    :: findstr /i "com/facebook/ads/AdManager com/mopub/mobileads com/applovin/mediation com/unity3d/ads/android com/ironsource/mediationsdk com/bytedance/sdk/openads com/chartboost/sdk com/inmobi/ads com/vungle/publisher com/mintegral/msdk com/tapjoy/TJAdUnit com/adcolony/sdk com/amazon/device/ads/AdRegistration" %APKCONTENTS% > %MATCHES%

    findstr /i /g:"%PATTERNS%" "%APKCONTENTS%" > "%MATCHES%"

    :: errorlevel=0 means matches found, therefore it has ads
    :: errorlevel=1 means no matches, therefore it does not have ads
    if errorlevel 1 (
    set /a COUNT_NOADS+=1
    del %MATCHES% 2>nul
    ) else (
    echo [ADS] %%A
    for /f %%X in (%MATCHES%) do echo %%X

    :: v1p8: append results to ADSOUT file
    echo APK: %%A >> "%ADSOUT%"
    for /f %%X in (%MATCHES%) do echo %%X >> "%ADSOUT%"
    echo. >> "%ADSOUT%"

    set /a COUNT_ADS+=1

    :: Save it for debugging
    copy "%MATCHES%" "scanads\matches_%%~nA.tmp" >nul

    del %MATCHES% 2>nul
    )
    )
    :: end scan loop

    echo.
    echo Scan complete.

    echo.
    echo Summary:
    echo Total APKs scanned: %COUNT_TOTAL%
    echo APKs containing ad-related files: %COUNT_ADS%
    echo APKs with no ad-related files: %COUNT_NOADS%
    echo.

    :: v1p8 show the file containing detailed ad-SDK results
    echo Detailed list saved to: %ADSOUT%
    echo.


    gvim %ADSOUT%
    pause
    :: This exit /b ends the main script
    exit /b

    REM Subroutine: ExtractPath
    REM Input: %1 = raw line from pm list packages -f
    REM Output: trimmed APK path (echoed)
    :ExtractPath
    setlocal enabledelayedexpansion

    set "line=%~1"

    REM Strip leading "package:"
    if /i "!line:~0,8!"=="package:" (
    set "line=!line:~8!"
    )

    REM Trim everything after the last "="
    set "tmp=!line!"
    :trimloop
    if "!tmp:~-1!"=="=" (
    set "tmp=!tmp:~0,-1!"
    goto :trimdone
    )
    set "tmp=!tmp:~0,-1!"
    if not "!tmp!"=="" goto :trimloop

    :trimdone
    echo !tmp!
    endlocal
    goto :eof

    :: This exit /b prevents CMD from falling into the label
    exit /b

    :: end of scanads.bat
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Fri Aug 7 00:17:40 2026
    From Newsgroup: alt.comp.os.windows-10

    On Thu, 8/6/2026 5:55 PM, Maria Sophia wrote:
    Stefan Ram wrote:
    You can remove the

    @echo off

    to get more context about where this message is coming from.

    Thanks Stefan, as this should run on anyone's Windows box with Android.
    My Android is connected over Wi-Fi via the adb connect script.

    I just saw this, so I'll just post my latest version, but it's still
    saying "The system cannot find the drive specified" for some reason.

    You can use Process Monitor, and watch for ReadFile/Writefile/CreateFile
    and see if any of those are reporting a failure similar to that. The
    failure path may be captured in the event for examination.

    https://learn.microsoft.com/en-us/sysinternals/downloads/procmon

    Paul
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Fri Aug 7 11:08:20 2026
    From Newsgroup: alt.comp.os.windows-10

    Maria Sophia <mariasophia@comprehension.com> wrote or quoted:
    I just saw this, so I'll just post my latest version, but it's still
    saying "The system cannot find the drive specified" for some reason.

    I assume "it" is "scanads.bat" on Windows.

    Do you know which line in "scanads.bat" says,
    "The system cannot find the drive specified"?


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Maria Sophia@mariasophia@comprehension.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Fri Aug 7 06:50:01 2026
    From Newsgroup: alt.comp.os.windows-10

    Stefan Ram wrote:
    Maria Sophia <mariasophia@comprehension.com> wrote or quoted:
    I just saw this, so I'll just post my latest version, but it's still
    saying "The system cannot find the drive specified" for some reason.

    I assume "it" is "scanads.bat" on Windows.

    Do you know which line in "scanads.bat" says,
    "The system cannot find the drive specified"?

    Hi Stefan,

    Thanks for asking. I'm at the point of giving up, and you know that because
    I'm asking for help, which I don't normally need to do for batch scripting.

    All I know is that the scanads.bat script doesn't have that line inside it.
    So the line is, most likely, coming from Windows.
    "The system cannot find the drive specified."

    I'm going to have to build a debug version, but this simple task has taken
    far too much energy out of me, as I thought it would be trivial to simply
    list all the files inside all the APKs on any given Android device.

    The *value* in that endeavor is of extreme importance, since, in the case
    of the advertising SDKs incorporated into apps, they're a known quantity.

    It should be this simple:
    1. List all the APKs on a device
    2. Unzip each apk into a list of files inside the APK
    3. Search for those that have known advertising SDK names

    I'm sure if I resorted to sed/grep/awk/etc., it would be trivial.
    But I'm trying to keep the script general purpose so all can use it.

    So I'm stuck with the horribly crappy way Windows handles complex lists.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Fri Aug 7 14:57:27 2026
    From Newsgroup: alt.comp.os.windows-10

    Maria Sophia <mariasophia@comprehension.com> wrote or quoted:
    Stefan Ram wrote:
    . . .
    I assume "it" is "scanads.bat" on Windows.
    Do you know which line in "scanads.bat" says,
    "The system cannot find the drive specified"?
    . . .
    All I know is that the scanads.bat script doesn't have that line inside it.

    If you remove "@echo off", Windows will print each line of the
    batch file as it executes it.

    The last line printed from the batch file before "The system
    cannot find the drive specified" is said, is responsible for
    this "The system cannot find the drive specified" message.

    It would help to find this line, by looking upwards from
    "The system cannot find the drive specified" with "@echo off"
    removed to see the last line from "scanads.bat" executed before
    "The system cannot find the drive specified" appears.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From JJ@jj4public@gmail.com to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Fri Aug 7 22:05:08 2026
    From Newsgroup: alt.comp.os.windows-10

    On Thu, 6 Aug 2026 20:02:36 -0000 (UTC), Maria Sophia wrote:
    Yesterday, the chain of events was such that:
    1. Stefan Ram posted a warning that Android APKs can leak location
    Message-ID: <locations-20260805220107@ram.dialup.fu-berlin.de>
    2. I then showed how use Win10 to determine if any apps leaked recently
    Message-ID: <1150g5v$1lsp$1@nnrp.usenet.blueworldhosting.com>
    3. But I then spent hours trying to confirm if any of my APKs "can" leak

    A. Windows can tell you if a device "has" leaked in the past time frame
    B. And, Windows can tell you if a device "can" leak in the future...
    [snip]

    Ideally, the APK's `AndroidManifest.xml` file should be checked. The
    manifest list all app's services, broadcast listeners, activities, and data providers; all in module name format aaa.bbb.ccc[...].
    e.g.: com.google.android.gms.ads.AdActivity

    But that file is in binary XML format instead of plain text XML format, so a binary XML parser tool will be needed to convert it to plain text. Then use
    an XML parser to extract specific part of the manifest.

    Since XML contains `<`, `>`, and `"` characters, it'd be troublesome (or
    even impossible) if handled using batch file. Other scripting tool should be used.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Herbert Kleebauer@klee@unibwm.de to comp.mobile.android,alt.msdos.batch,alt.comp.os.windows-10 on Fri Aug 7 22:15:52 2026
    From Newsgroup: alt.comp.os.windows-10

    On 8/6/2026 10:22 PM, Maria Sophia wrote:

    Specifically, how do we turn this:
    package:/data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk=com.wemagineai.voila

    Into this (without knowing the name of the package ahead of time)
    /data/app/~~0H1-2NstdUVjAZffiA36og==/com.wemagineai.voila-eUnm7DkWz754o5t0a88gdA==/base.apk

    That isn't a job for a batch program. Use a scriptable editor, PowerShell
    or even C code. If it has to be done in a batch, process the input file
    byte by byte: the following code skips anything including the first ":".
    Then outputs the following bytes till the 5. "=" and the skips the rest
    of the line. But it is extremely slow.


    @echo off
    setlocal enabledelayedexpansion

    set infile=in.txt
    set outfile=out.txt

    set tmp0=_tmp0.tmp
    if exist %tmp0% del %tmp0%

    call :fopen %infile%
    echo %infile% opened as input file

    :::::::::::::::::::::::::::::::::::::::::::::::::::::

    set n=-1

    :l1
    set /a n=n+1
    call :getc_hex char %n%
    if -1==%char% goto :end
    if not 3a==%char% goto :l1
    set m=0

    :l3
    set /a n=n+1
    call :getc_hex char %n%
    if -1==%char% goto :end
    if 3d==%char% set /a m=m+1
    if %m%==5 goto :l2
    echo %char%>>%tmp0%
    goto :l3

    :l2
    set /a n=n+1
    call :getc_hex char %n%
    if -1==%char% goto :end
    if not 0a==%char% goto :l2
    echo 0d 0a>>%tmp0%
    goto :l1


    :end
    :: convert hexfile tmp1 to binary outfile
    certutil -f -decodehex %tmp0% %outfile% >nul


    if exist %tmp0% del %tmp0%
    call :fclose
    goto :eof


    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :fopen
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    set tmp1=_tmp1.tmp
    set tmp2=_tmp2.tmp
    set fsize=%~z1
    set cache=-1
    certutil -f -encodehex %1 %tmp1% 4 >nul
    set n=0
    if exist %tmp2% del %tmp2%

    for /f "tokens=1-16" %%a in (%tmp1%) do (
    set /p =%%a%%b%%c%%d%%e%%f%%g%%h%%i%%j%%k%%l%%m%%n%%o%%p<nul >>%tmp2%
    set /a n=n+1
    if !n!==64 echo.>>%tmp2% & set n=0)

    goto :eof

    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :fclose
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    del %tmp1%
    del %tmp2%
    goto :eof


    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :getc_hex :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    if %2 GEQ %fsize% set /a %1=-1 & goto :eof
    set /a i=%2/1024 & set /a j=2*(%2%%1024)
    if %i%==%cache% goto :skip
    echo read cache line %i%
    set cache=%i%
    set skip=
    if %i% GEQ 1 set skip="skip=%i%"
    for /f %skip% %%i in (%tmp2%) do (
    set line=%%i & goto :skip)
    :skip
    call set %1=%%line:~%j%,2%%
    goto :eof



    --- Synchronet 3.22a-Linux NewsLink 1.2