-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.txt
More file actions
2548 lines (2193 loc) · 72.2 KB
/
code.txt
File metadata and controls
2548 lines (2193 loc) · 72.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Appranium — Complete V2 Architecture Plan
## Master Document for AI-Assisted Code Generation
---
## 1. Project Identity
```
Name: Appranium
Type: React Single-Page Application (SPA)
Hosting: Static (Netlify / Vercel / GitHub Pages)
Backend: NONE
Data Storage: NONE
API Keys: NONE
Cost: 100% FREE
Privacy: All processing in-browser, zero uploads
```
---
## 2. Technology Stack
```
Framework: React 18+ (Create React App or Vite)
Language: JavaScript (ES6+)
Styling: CSS Modules or plain CSS (no Tailwind CDN — bundle locally or use CSS)
ZIP Parsing: JSZip (free, already used)
Charts: Recharts (free, React-native charting)
Icons: react-icons (free)
Animations: CSS keyframes (no library needed)
Build Tool: Vite (preferred) or CRA
Package Mgr: npm
```
---
## 3. Complete Folder Structure
```
appranium/
├── public/
│ ├── index.html
│ ├── favicon.ico
│ └── manifest.json
├── src/
│ ├── index.js
│ ├── App.js
│ ├── App.css
│ │
│ ├── components/
│ │ ├── Header/
│ │ │ ├── Header.jsx
│ │ │ └── Header.css
│ │ ├── FileUpload/
│ │ │ ├── FileUpload.jsx
│ │ │ └── FileUpload.css
│ │ ├── PrivacyBadge/
│ │ │ ├── PrivacyBadge.jsx
│ │ │ └── PrivacyBadge.css
│ │ ├── AppOverview/
│ │ │ ├── AppOverview.jsx
│ │ │ └── AppOverview.css
│ │ ├── RiskScore/
│ │ │ ├── RiskScore.jsx
│ │ │ └── RiskScore.css
│ │ ├── SuspiciousCombos/
│ │ │ ├── SuspiciousCombos.jsx
│ │ │ └── SuspiciousCombos.css
│ │ ├── ManifestWarnings/
│ │ │ ├── ManifestWarnings.jsx
│ │ │ └── ManifestWarnings.css
│ │ ├── ComponentExposure/
│ │ │ ├── ComponentExposure.jsx
│ │ │ └── ComponentExposure.css
│ │ ├── RiskCharts/
│ │ │ ├── RiskCharts.jsx
│ │ │ └── RiskCharts.css
│ │ ├── PermissionBreakdown/
│ │ │ ├── PermissionBreakdown.jsx
│ │ │ └── PermissionBreakdown.css
│ │ ├── DataExposureProfile/
│ │ │ ├── DataExposureProfile.jsx
│ │ │ └── DataExposureProfile.css
│ │ ├── SearchFilter/
│ │ │ ├── SearchFilter.jsx
│ │ │ └── SearchFilter.css
│ │ ├── EducationalInsights/
│ │ │ ├── EducationalInsights.jsx
│ │ │ └── EducationalInsights.css
│ │ ├── Footer/
│ │ │ ├── Footer.jsx
│ │ │ └── Footer.css
│ │ └── common/
│ │ ├── Badge.jsx
│ │ ├── Card.jsx
│ │ ├── GaugeCircle.jsx
│ │ ├── Collapsible.jsx
│ │ └── common.css
│ │
│ ├── utils/
│ │ ├── fileHandler.js
│ │ ├── manifestParser.js
│ │ ├── permissionExtractor.js
│ │ ├── riskScorer.js
│ │ ├── comboDetector.js
│ │ ├── manifestAnalyzer.js
│ │ ├── componentAnalyzer.js
│ │ ├── metadataExtractor.js
│ │ └── domainCategorizer.js
│ │
│ ├── data/
│ │ ├── permissionDatabase.js
│ │ ├── suspiciousCombos.js
│ │ ├── domainCategories.js
│ │ └── educationalContent.js
│ │
│ └── hooks/
│ └── useAnalysis.js
│
├── package.json
├── vite.config.js (or react-scripts config)
└── README.md
```
---
## 4. Package.json Dependencies
```json
{
"name": "appranium",
"version": "2.0.0",
"private": true,
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"jszip": "^3.10.1",
"recharts": "^2.12.0",
"react-icons": "^5.0.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.2.0",
"vite": "^5.0.0"
},
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}
}
```
---
## 5. Complete Data Layer Specifications
---
### 5A. `src/data/permissionDatabase.js`
This is the master dictionary. Every permission maps to a risk tier, a human description, and a data domain category.
```javascript
// FULL EXPORT — single default object
// Keys: full Android permission string
// Values: { risk, description, category }
const PERMISSION_DATABASE = {
// ========== HIGH RISK ==========
'android.permission.CAMERA': {
risk: 'high',
description: 'Access the device camera to take photos and record video.',
category: 'Device Control'
},
'android.permission.RECORD_AUDIO': {
risk: 'high',
description: 'Record audio using the device microphone.',
category: 'Device Control'
},
'android.permission.ACCESS_FINE_LOCATION': {
risk: 'high',
description: 'Access precise GPS location of the device.',
category: 'Location'
},
'android.permission.ACCESS_COARSE_LOCATION': {
risk: 'high',
description: 'Access approximate location via network triangulation.',
category: 'Location'
},
'android.permission.ACCESS_BACKGROUND_LOCATION': {
risk: 'high',
description: 'Access location even when the app is in background.',
category: 'Location'
},
'android.permission.READ_CONTACTS': {
risk: 'high',
description: 'Read all contacts stored on the device.',
category: 'Identity'
},
'android.permission.WRITE_CONTACTS': {
risk: 'high',
description: 'Modify or delete contacts on the device.',
category: 'Identity'
},
'android.permission.READ_CALL_LOG': {
risk: 'high',
description: 'Read the user call history.',
category: 'Communication'
},
'android.permission.WRITE_CALL_LOG': {
risk: 'high',
description: 'Modify or delete call log entries.',
category: 'Communication'
},
'android.permission.READ_SMS': {
risk: 'high',
description: 'Read SMS messages stored on the device.',
category: 'Communication'
},
'android.permission.SEND_SMS': {
risk: 'high',
description: 'Send SMS messages, potentially incurring charges.',
category: 'Communication'
},
'android.permission.RECEIVE_SMS': {
risk: 'high',
description: 'Intercept incoming SMS messages.',
category: 'Communication'
},
'android.permission.READ_PHONE_STATE': {
risk: 'high',
description: 'Access phone number, IMEI, carrier info, and call state.',
category: 'Identity'
},
'android.permission.READ_PHONE_NUMBERS': {
risk: 'high',
description: 'Access the phone numbers associated with the device.',
category: 'Identity'
},
'android.permission.CALL_PHONE': {
risk: 'high',
description: 'Initiate phone calls without user interaction.',
category: 'Communication'
},
'android.permission.READ_EXTERNAL_STORAGE': {
risk: 'high',
description: 'Read files from shared/external storage.',
category: 'Storage'
},
'android.permission.WRITE_EXTERNAL_STORAGE': {
risk: 'high',
description: 'Write or delete files on shared/external storage.',
category: 'Storage'
},
'android.permission.READ_MEDIA_IMAGES': {
risk: 'high',
description: 'Access photos and images on the device.',
category: 'Storage'
},
'android.permission.READ_MEDIA_VIDEO': {
risk: 'high',
description: 'Access video files on the device.',
category: 'Storage'
},
'android.permission.READ_MEDIA_AUDIO': {
risk: 'high',
description: 'Access audio files on the device.',
category: 'Storage'
},
'android.permission.READ_CALENDAR': {
risk: 'high',
description: 'Read calendar events and details.',
category: 'Identity'
},
'android.permission.WRITE_CALENDAR': {
risk: 'high',
description: 'Create or modify calendar events.',
category: 'Identity'
},
'android.permission.BODY_SENSORS': {
risk: 'high',
description: 'Access body sensors like heart rate monitor.',
category: 'Health'
},
'android.permission.ACTIVITY_RECOGNITION': {
risk: 'high',
description: 'Detect physical activity (walking, driving, etc.).',
category: 'Health'
},
'android.permission.SYSTEM_ALERT_WINDOW': {
risk: 'high',
description: 'Draw overlays on top of other apps. Used in phishing attacks.',
category: 'Device Control'
},
'android.permission.REQUEST_INSTALL_PACKAGES': {
risk: 'high',
description: 'Request installation of additional APK packages.',
category: 'Device Control'
},
'android.permission.MANAGE_EXTERNAL_STORAGE': {
risk: 'high',
description: 'Full access to all files on external storage.',
category: 'Storage'
},
'android.permission.GET_ACCOUNTS': {
risk: 'high',
description: 'Access the list of accounts registered on the device.',
category: 'Identity'
},
'android.permission.USE_BIOMETRIC': {
risk: 'high',
description: 'Use biometric hardware (fingerprint, face).',
category: 'Identity'
},
'android.permission.BIND_ACCESSIBILITY_SERVICE': {
risk: 'high',
description: 'Bind to an accessibility service. Can monitor all UI events.',
category: 'Device Control'
},
'android.permission.BIND_DEVICE_ADMIN': {
risk: 'high',
description: 'Act as a device administrator. Can lock/wipe device.',
category: 'Device Control'
},
'android.permission.PROCESS_OUTGOING_CALLS': {
risk: 'high',
description: 'Monitor, modify, or abort outgoing calls.',
category: 'Communication'
},
'android.permission.RECEIVE_MMS': {
risk: 'high',
description: 'Intercept incoming MMS messages.',
category: 'Communication'
},
'android.permission.RECEIVE_WAP_PUSH': {
risk: 'high',
description: 'Receive WAP push messages.',
category: 'Communication'
},
// ========== MEDIUM RISK ==========
'android.permission.INTERNET': {
risk: 'medium',
description: 'Full network access to send and receive data.',
category: 'Network'
},
'android.permission.ACCESS_NETWORK_STATE': {
risk: 'medium',
description: 'View network connection status (WiFi, mobile data).',
category: 'Network'
},
'android.permission.ACCESS_WIFI_STATE': {
risk: 'medium',
description: 'View WiFi connection information.',
category: 'Network'
},
'android.permission.CHANGE_WIFI_STATE': {
risk: 'medium',
description: 'Connect to and disconnect from WiFi networks.',
category: 'Network'
},
'android.permission.CHANGE_NETWORK_STATE': {
risk: 'medium',
description: 'Change network connectivity state.',
category: 'Network'
},
'android.permission.BLUETOOTH': {
risk: 'medium',
description: 'Access Bluetooth connectivity.',
category: 'Network'
},
'android.permission.BLUETOOTH_ADMIN': {
risk: 'medium',
description: 'Discover and pair with Bluetooth devices.',
category: 'Network'
},
'android.permission.BLUETOOTH_CONNECT': {
risk: 'medium',
description: 'Connect to paired Bluetooth devices.',
category: 'Network'
},
'android.permission.BLUETOOTH_SCAN': {
risk: 'medium',
description: 'Discover nearby Bluetooth devices.',
category: 'Network'
},
'android.permission.NFC': {
risk: 'medium',
description: 'Perform NFC (Near Field Communication) operations.',
category: 'Network'
},
'android.permission.VIBRATE': {
risk: 'low',
description: 'Control the device vibration motor.',
category: 'Device Control'
},
'android.permission.RECEIVE_BOOT_COMPLETED': {
risk: 'medium',
description: 'Auto-start the app when the device boots.',
category: 'Device Control'
},
'android.permission.FOREGROUND_SERVICE': {
risk: 'medium',
description: 'Run a foreground service with persistent notification.',
category: 'Device Control'
},
'android.permission.FOREGROUND_SERVICE_LOCATION': {
risk: 'medium',
description: 'Run a foreground service that accesses location.',
category: 'Location'
},
'android.permission.FOREGROUND_SERVICE_CAMERA': {
risk: 'medium',
description: 'Run a foreground service that accesses camera.',
category: 'Device Control'
},
'android.permission.FOREGROUND_SERVICE_MICROPHONE': {
risk: 'medium',
description: 'Run a foreground service that accesses microphone.',
category: 'Device Control'
},
'android.permission.POST_NOTIFICATIONS': {
risk: 'medium',
description: 'Send push notifications to the user.',
category: 'Device Control'
},
'android.permission.SCHEDULE_EXACT_ALARM': {
risk: 'medium',
description: 'Schedule alarms at exact times.',
category: 'Device Control'
},
'android.permission.USE_EXACT_ALARM': {
risk: 'medium',
description: 'Use exact alarm scheduling.',
category: 'Device Control'
},
'android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS': {
risk: 'medium',
description: 'Request exemption from battery optimization.',
category: 'Device Control'
},
'com.google.android.gms.permission.AD_ID': {
risk: 'medium',
description: 'Access the Google Advertising ID for ad tracking.',
category: 'Identity'
},
'android.permission.QUERY_ALL_PACKAGES': {
risk: 'medium',
description: 'See all installed apps on the device.',
category: 'Identity'
},
'com.android.vending.BILLING': {
risk: 'medium',
description: 'Process in-app purchases via Google Play.',
category: 'Financial'
},
'android.permission.WAKE_LOCK': {
risk: 'medium',
description: 'Prevent the device from sleeping.',
category: 'Device Control'
},
// ========== LOW RISK ==========
'android.permission.ACCESS_NOTIFICATION_POLICY': {
risk: 'low',
description: 'Access the Do Not Disturb notification policy.',
category: 'Device Control'
},
'android.permission.SET_WALLPAPER': {
risk: 'low',
description: 'Set the device wallpaper.',
category: 'Device Control'
},
'android.permission.SET_ALARM': {
risk: 'low',
description: 'Set an alarm in the default alarm clock app.',
category: 'Device Control'
},
'android.permission.FLASHLIGHT': {
risk: 'low',
description: 'Access the device flashlight.',
category: 'Device Control'
},
'android.permission.EXPAND_STATUS_BAR': {
risk: 'low',
description: 'Expand or collapse the status bar.',
category: 'Device Control'
},
'android.permission.REORDER_TASKS': {
risk: 'low',
description: 'Reorder running tasks.',
category: 'Device Control'
},
'android.permission.SET_WALLPAPER_HINTS': {
risk: 'low',
description: 'Set wallpaper size hints.',
category: 'Device Control'
}
};
export default PERMISSION_DATABASE;
```
**IMPORTANT:** Any permission found in the APK that is NOT in this dictionary must be classified as `unknown` risk with a generic description:
```javascript
// fallback for unknown permissions
{
risk: 'unknown',
description: 'This permission is not in our database. Review manually.',
category: 'Unknown'
}
```
---
### 5B. `src/data/suspiciousCombos.js`
```javascript
const SUSPICIOUS_COMBOS = [
{
id: 'surveillance-av',
combo: ['android.permission.CAMERA', 'android.permission.RECORD_AUDIO'],
risk: 'critical',
title: 'Audio + Video Surveillance',
reason: 'App can record both audio and video simultaneously, enabling full surveillance capability.'
},
{
id: 'otp-theft',
combo: ['android.permission.READ_SMS', 'android.permission.INTERNET'],
risk: 'critical',
title: 'OTP / SMS Interception',
reason: 'App can read SMS messages (including OTPs) and transmit them to external servers.'
},
{
id: 'location-tracking',
combo: ['android.permission.ACCESS_FINE_LOCATION', 'android.permission.INTERNET'],
risk: 'high',
title: 'Real-Time Location Tracking',
reason: 'App can track precise GPS location and send it to remote servers in real time.'
},
{
id: 'overlay-phishing',
combo: ['android.permission.SYSTEM_ALERT_WINDOW', 'android.permission.READ_SMS'],
risk: 'critical',
title: 'Overlay Phishing + SMS Theft',
reason: 'App can draw fake login screens over other apps while intercepting SMS verification codes.'
},
{
id: 'contact-exfiltration',
combo: ['android.permission.READ_CONTACTS', 'android.permission.INTERNET'],
risk: 'high',
title: 'Contact Data Exfiltration',
reason: 'App can read entire contact list and upload it to external servers.'
},
{
id: 'call-interception',
combo: ['android.permission.PROCESS_OUTGOING_CALLS', 'android.permission.RECORD_AUDIO'],
risk: 'critical',
title: 'Call Monitoring + Recording',
reason: 'App can intercept outgoing calls and record audio during calls.'
},
{
id: 'file-exfiltration',
combo: ['android.permission.READ_EXTERNAL_STORAGE', 'android.permission.INTERNET'],
risk: 'high',
title: 'File Data Exfiltration',
reason: 'App can read all files on external storage and transmit them over network.'
},
{
id: 'background-location',
combo: ['android.permission.ACCESS_BACKGROUND_LOCATION', 'android.permission.INTERNET'],
risk: 'critical',
title: 'Background Location Surveillance',
reason: 'App can continuously track location even when not in use and send data externally.'
},
{
id: 'sms-financial',
combo: ['android.permission.READ_SMS', 'android.permission.SEND_SMS'],
risk: 'critical',
title: 'Full SMS Control',
reason: 'App can both read and send SMS messages. Can be used for premium SMS fraud or message manipulation.'
},
{
id: 'silent-install',
combo: ['android.permission.REQUEST_INSTALL_PACKAGES', 'android.permission.INTERNET'],
risk: 'critical',
title: 'Remote APK Installation',
reason: 'App can download and install additional APKs from the internet.'
},
{
id: 'identity-harvest',
combo: ['android.permission.GET_ACCOUNTS', 'android.permission.READ_CONTACTS', 'android.permission.INTERNET'],
risk: 'critical',
title: 'Identity Harvesting',
reason: 'App can access accounts, contacts, and transmit identity information externally.'
},
{
id: 'camera-upload',
combo: ['android.permission.CAMERA', 'android.permission.INTERNET'],
risk: 'high',
title: 'Photo/Video Capture & Upload',
reason: 'App can take photos or record video and upload them to external servers.'
}
];
export default SUSPICIOUS_COMBOS;
```
---
### 5C. `src/data/domainCategories.js`
```javascript
// Maps category names to display metadata
const DOMAIN_CATEGORIES = {
'Location': {
icon: '📍',
color: '#e74c3c',
description: 'Permissions that access device location data.'
},
'Communication': {
icon: '📞',
color: '#e67e22',
description: 'Permissions related to calls, SMS, and messaging.'
},
'Identity': {
icon: '👤',
color: '#9b59b6',
description: 'Permissions accessing personal identity information.'
},
'Device Control': {
icon: '⚙️',
color: '#3498db',
description: 'Permissions controlling device hardware and features.'
},
'Storage': {
icon: '📁',
color: '#f39c12',
description: 'Permissions accessing files and media storage.'
},
'Network': {
icon: '🌐',
color: '#1abc9c',
description: 'Permissions related to internet and network access.'
},
'Financial': {
icon: '💳',
color: '#e74c3c',
description: 'Permissions related to billing and financial transactions.'
},
'Health': {
icon: '❤️',
color: '#e84393',
description: 'Permissions accessing health and fitness sensors.'
},
'Unknown': {
icon: '❓',
color: '#95a5a6',
description: 'Permissions not in our categorization database.'
}
};
export default DOMAIN_CATEGORIES;
```
---
### 5D. `src/data/educationalContent.js`
```javascript
const EDUCATIONAL_CONTENT = [
{
id: 'runtime-permissions',
title: 'Runtime Permissions (Android 6.0+)',
content: `Starting with Android 6.0 (API level 23), dangerous permissions
must be requested at runtime, not just declared in the manifest. This means
the user sees a dialog before granting sensitive permissions like Camera or
Location. Apps targeting SDK 22 or below bypass this protection entirely
and receive all permissions at install time.`
},
{
id: 'scoped-storage',
title: 'Scoped Storage (Android 10+)',
content: `Android 10 introduced scoped storage, restricting apps from
freely accessing shared external storage. Apps can only access their own
app-specific directory and specific media files they created. Apps
requesting MANAGE_EXTERNAL_STORAGE bypass this restriction and gain
full file system access — a significant privacy concern.`
},
{
id: 'background-location',
title: 'Background Location Restrictions (Android 10+)',
content: `Android 10+ requires a separate permission
(ACCESS_BACKGROUND_LOCATION) for apps to access location while running
in the background. Users must explicitly grant this through Settings,
not just a dialog. Apps with this permission can continuously track
your location even when you're not actively using them.`
},
{
id: 'overlay-attacks',
title: 'Overlay Attacks (SYSTEM_ALERT_WINDOW)',
content: `The SYSTEM_ALERT_WINDOW permission allows an app to draw on
top of other apps. While legitimate uses exist (chat bubbles, screen
tools), malicious apps can use this to create fake login screens that
capture credentials. This is known as a "tapjacking" or "overlay" attack.`
},
{
id: 'exported-components',
title: 'Exported Components Risk',
content: `When an Android component (Activity, Service, Receiver, Provider)
is marked as exported="true", other apps on the device can interact with it.
Without proper permission checks, this can allow unauthorized apps to trigger
functionality, access data, or exploit the component.`
},
{
id: 'debug-builds',
title: 'Debug Builds in Production',
content: `If an APK has android:debuggable="true" in its manifest, it
means the app was built in debug mode. This allows anyone to attach a
debugger, inspect memory, and bypass security checks. Production apps
should never have this flag enabled.`
}
];
export default EDUCATIONAL_CONTENT;
```
---
## 6. Utility Layer — Complete Logic Specifications
---
### 6A. `src/utils/fileHandler.js`
**Purpose:** Accept `.apk` or `.xml` file, extract the AndroidManifest.xml content as a string.
```javascript
// PSEUDOCODE / SPEC
import JSZip from 'jszip';
/**
* @param {File} file - The uploaded file (.apk or .xml)
* @returns {Promise<{manifestContent: string, fileType: string, fileName: string}>}
*/
export async function handleFile(file) {
const fileName = file.name;
const extension = fileName.split('.').pop().toLowerCase();
if (extension === 'xml') {
// Read as plain text
const text = await file.text();
return {
manifestContent: text,
fileType: 'xml',
fileName: fileName
};
}
if (extension === 'apk') {
// Read as ArrayBuffer, then unzip
const arrayBuffer = await file.arrayBuffer();
const zip = await JSZip.loadAsync(arrayBuffer);
// Look for AndroidManifest.xml
const manifestEntry = zip.file('AndroidManifest.xml');
if (!manifestEntry) {
throw new Error('AndroidManifest.xml not found inside the APK.');
}
// Try reading as text first
let content = await manifestEntry.async('text');
// If content contains binary/garbled characters (compiled XML),
// read as uint8array and attempt binary extraction
if (isBinaryXml(content)) {
const binaryData = await manifestEntry.async('uint8array');
content = extractFromBinaryXml(binaryData);
}
return {
manifestContent: content,
fileType: 'apk',
fileName: fileName
};
}
throw new Error('Unsupported file type. Please upload an .apk or .xml file.');
}
/**
* Check if content appears to be binary (compiled) XML
*/
function isBinaryXml(content) {
// Binary Android XML starts with 0x00 0x00 or 0x03 0x00
// or contains many null characters
const nullCount = (content.match(/\0/g) || []).length;
return nullCount > content.length * 0.1;
}
/**
* Extract readable strings from binary XML
* This is a simplified extraction — pulls all readable strings
* including permission names and attribute values
*/
function extractFromBinaryXml(uint8array) {
// Strategy: scan for readable ASCII/UTF-8 strings
// Android binary XML stores strings in a string pool
// We extract all strings that look like:
// - android.permission.*
// - package names
// - attribute values (true/false, version numbers)
// - tag names (activity, service, receiver, provider)
const strings = [];
let current = '';
for (let i = 0; i < uint8array.length; i++) {
const byte = uint8array[i];
// Printable ASCII range
if (byte >= 32 && byte <= 126) {
current += String.fromCharCode(byte);
} else {
if (current.length >= 3) {
strings.push(current);
}
current = '';
}
}
if (current.length >= 3) {
strings.push(current);
}
// Reconstruct a pseudo-manifest for parsing
return strings.join('\n');
}
```
---
### 6B. `src/utils/permissionExtractor.js`
**Purpose:** Extract all Android permissions from manifest content string.
```javascript
/**
* @param {string} manifestContent - Raw or pseudo manifest text
* @returns {string[]} - Array of full permission strings
*/
export function extractPermissions(manifestContent) {
const permissions = new Set();
// Pattern 1: Standard XML uses-permission tag
const xmlPattern = /uses-permission\s[^>]*android:name\s*=\s*"([^"]+)"/gi;
let match;
while ((match = xmlPattern.exec(manifestContent)) !== null) {
permissions.add(match[1].trim());
}
// Pattern 2: Direct permission string match (for binary extracted content)
const directPattern = /android\.permission\.[A-Z_]+/g;
while ((match = directPattern.exec(manifestContent)) !== null) {
permissions.add(match[0].trim());
}
// Pattern 3: Custom/third-party permissions
const customPattern = /com\.[a-z0-9]+(?:\.[a-z0-9]+)*\.permission\.[A-Z_]+/gi;
while ((match = customPattern.exec(manifestContent)) !== null) {
permissions.add(match[0].trim());
}
// Pattern 4: Google-specific permissions
const googlePattern = /com\.google\.android\.[a-z0-9.]*permission\.[A-Z_]+/gi;
while ((match = googlePattern.exec(manifestContent)) !== null) {
permissions.add(match[0].trim());
}
return Array.from(permissions).sort();
}
```
---
### 6C. `src/utils/riskScorer.js`
**Purpose:** Calculate weighted privacy risk score from permission list.
```javascript
import PERMISSION_DATABASE from '../data/permissionDatabase';
const WEIGHTS = {
high: 20,
medium: 10,
low: 2,
unknown: 5
};
const GRADES = [
{ max: 29, grade: 'A', label: 'Low Risk', color: '#27ae60' },
{ max: 49, grade: 'B', label: 'Moderate', color: '#f1c40f' },
{ max: 69, grade: 'C', label: 'Elevated', color: '#e67e22' },
{ max: 84, grade: 'D', label: 'High', color: '#e74c3c' },
{ max: 100, grade: 'F', label: 'Critical', color: '#c0392b' }
];
/**
* @param {string[]} permissions - Array of permission strings
* @returns {{
* score: number,
* normalizedScore: number,
* grade: string,
* label: string,
* color: string,
* breakdown: {high: number, medium: number, low: number, unknown: number},
* explanation: string
* }}
*/
export function calculateRiskScore(permissions) {
const breakdown = { high: 0, medium: 0, low: 0, unknown: 0 };
permissions.forEach(perm => {
const entry = PERMISSION_DATABASE[perm];
if (entry) {
breakdown[entry.risk] = (breakdown[entry.risk] || 0) + 1;
} else {
breakdown.unknown += 1;
}
});
const rawScore =
(breakdown.high * WEIGHTS.high) +
(breakdown.medium * WEIGHTS.medium) +
(breakdown.low * WEIGHTS.low) +
(breakdown.unknown * WEIGHTS.unknown);
const normalizedScore = Math.min(100, rawScore);
// Determine grade
let gradeInfo = GRADES[GRADES.length - 1]; // default to worst
for (const g of GRADES) {
if (normalizedScore <= g.max) {
gradeInfo = g;
break;
}
}
// Generate explanation
let explanation = '';
if (normalizedScore <= 29) {
explanation = 'This app requests minimal permissions with low privacy impact.';
} else if (normalizedScore <= 49) {
explanation = 'This app requests some permissions that could affect privacy. Review the details below.';
} else if (normalizedScore <= 69) {
explanation = 'This app requests several sensitive permissions. Consider whether all are necessary.';
} else if (normalizedScore <= 84) {
explanation = 'This app requests multiple high-risk permissions that significantly impact user privacy.';
} else {
explanation = 'This app requests an alarming number of sensitive permissions. Extreme caution is advised.';
}
return {
score: rawScore,
normalizedScore,
grade: gradeInfo.grade,
label: gradeInfo.label,
color: gradeInfo.color,
breakdown,
explanation
};
}
```
---
### 6D. `src/utils/comboDetector.js`
**Purpose:** Detect suspicious permission combinations.
```javascript
import SUSPICIOUS_COMBOS from '../data/suspiciousCombos';
/**
* @param {string[]} permissions - Array of permission strings
* @returns {Array<{id, combo, risk, title, reason, matched}>}
*/
export function detectSuspiciousCombos(permissions) {
const permSet = new Set(permissions);
const detected = [];
SUSPICIOUS_COMBOS.forEach(rule => {
const allPresent = rule.combo.every(perm => permSet.has(perm));
if (allPresent) {
detected.push({
...rule,