ai_root_shield 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0d354e66eecc271bd43c8ac6625c186a3aa38789ac19abbe5eabc0bf4fc1641
4
- data.tar.gz: f2ce01ca5f411532737549e534db15dd1be0f942c3ef3427e1685a4fe7c964da
3
+ metadata.gz: 7aa3147f758f9775ee0b5739aa6edf8c6a905052b72760bbbe5991c80a2c4925
4
+ data.tar.gz: bc5d646ce2e6c86bceef124763ed0ff3168a70bb90c6946f24e8e37fe5310df4
5
5
  SHA512:
6
- metadata.gz: 05e5cfacfef14284c46aa5dbc7ae33ae5a1f70a5262c6341de8b22e968feb71c4e2f91385672d3032ea02e47ab1d21d504dfe4c0a3bb2134b9807aaea7647554
7
- data.tar.gz: 0cc0cd97dab91107681bbbe04951f8c966a23de3e35965e8ed0d50afba5212133c2ef41b569560000c73b2b9ee22b869d22994ed73ca57749e1345c09a36e89d
6
+ metadata.gz: 8a1160dbbbc26d2956ec0262ec5fbeeacce25335229cafdce11d88311bffe1fa040d060b47db07aff39344f3bd7f468433ea5ca2d4d768fc5d39d7e8b898de05
7
+ data.tar.gz: 0cfb012442a47483f041651fc47089348e115c1837583d54de71584f5678e5ccc34458f98adf40084f49d7149459e7c0d7f01fa9d8dd4af77b77ae76b06aeb44
data/CHANGELOG.md CHANGED
@@ -12,6 +12,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
  - Real-time threat monitoring capabilities
13
13
  - Custom rule engine for security policies
14
14
 
15
+ ## [0.4.0] - 2024-12-XX
16
+
17
+ ### Added
18
+ - **Advanced Network Security** capabilities
19
+ - Certificate pinning helper with TLS public key pinning integration
20
+ - Advanced proxy detection (VPN, Tor, custom DNS, MITM appliance detection)
21
+ - Enterprise policy management with JSON-based customizable security rules
22
+ - Policy compliance validation and violation reporting
23
+ - Network security analysis integration
24
+ - Support for banking, enterprise, and development policy templates
25
+ - CLI support for network security features (`--enable-cert-pinning`, `--enable-proxy-detection`, `--policy`)
26
+
27
+ ### Enhanced
28
+ - Comprehensive security status reporting across all components
29
+ - Enhanced CLI with network analysis options (`--target-ip`, `--target-url`)
30
+ - Policy-driven risk assessment and compliance checking
31
+ - Real-time network threat detection and reporting
32
+
33
+ ### Technical
34
+ - Certificate chain validation and pin extraction
35
+ - Multi-layered proxy detection (Tor exit nodes, VPN services, MITM appliances)
36
+ - JSON policy definition with inheritance and merging
37
+ - Audit logging and compliance reporting
38
+ - Network analysis integration with existing risk calculation
39
+
15
40
  ## [0.3.0] - 2024-01-03
16
41
 
17
42
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ai_root_shield (0.3.0)
4
+ ai_root_shield (0.4.0)
5
5
  digest (~> 3.1)
6
6
  json (~> 2.6)
7
7
  numo-narray (~> 0.9)
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
  [![Ruby](https://img.shields.io/badge/ruby-%23CC342D.svg?style=flat&logo=ruby&logoColor=white)](https://www.ruby-lang.org/)
6
6
  [![Security](https://img.shields.io/badge/security-first-green.svg)](https://github.com/ahmetxhero/ai-root-shield)
7
+ [![Buy Me A Coffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-support%20my%20work-FFDD00?style=flat&logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/ahmetxhero)
7
8
 
8
9
  > **Created by [Ahmet KAHRAMAN](https://ahmetxhero.web.app)** - Mobile Developer & Cyber Security Expert
9
10
  > *"Security first, innovation always"* 🛡️
@@ -17,11 +18,15 @@ An AI-powered Ruby library that performs comprehensive on-device compromise dete
17
18
  - **Hooking Framework Detection**: Detects Frida, Xposed, Substrate, and other instrumentation tools
18
19
  - **Application Integrity Checks**: Validates app signatures and detects repackaging/tampering
19
20
  - **Network Security Analysis**: Identifies TLS issues, custom CAs, and MITM tools
20
- - **🆕 RASP Protection**: Runtime Application Self-Protection with real-time threat blocking
21
- - **🆕 Anti-Debug Mechanisms**: Ptrace, GDB, LLDB detection and blocking
22
- - **🆕 Anti-Tamper Protection**: Code integrity and memory patch detection
23
- - **🆕 Dynamic Memory Protection**: Frida injection hook mitigation
24
- - **🆕 Runtime Integrity Monitor**: Critical function hash validation
21
+ - **🆕 Advanced Network Security**: Certificate pinning helper and comprehensive proxy detection
22
+ - **🆕 Enterprise Policy Management**: JSON-based customizable security rules and compliance validation
23
+ - **🆕 Certificate Pinning Helper**: TLS public key pinning with easy integration
24
+ - **🆕 Advanced Proxy Detection**: VPN, Tor, custom DNS, and MITM appliance detection
25
+ - **RASP Protection**: Runtime Application Self-Protection with real-time threat blocking
26
+ - **Anti-Debug Mechanisms**: Ptrace, GDB, LLDB detection and blocking
27
+ - **Anti-Tamper Protection**: Code integrity and memory patch detection
28
+ - **Dynamic Memory Protection**: Frida injection hook mitigation
29
+ - **Runtime Integrity Monitor**: Critical function hash validation
25
30
  - **AI Behavioral Analysis**: ONNX-powered behavioral pattern analysis with anomaly detection
26
31
  - **ML-Based Emulator Detection**: Advanced machine learning techniques for emulator identification
27
32
  - **AI Confidence Scoring**: Confidence metrics integrated into risk assessment
@@ -132,7 +137,54 @@ puts "AI Confidence: #{result[:ai_confidence]}"
132
137
  puts "ML Emulator Score: #{result[:ml_emulator_score]}"
133
138
  ```
134
139
 
135
- ## RASP Protection (New in v0.3.0)
140
+ ## Advanced Network Security & Policy Management (New in v0.4.0)
141
+
142
+ Enterprise-grade network security and policy management capabilities:
143
+
144
+ ### Features
145
+ - **Certificate Pinning Helper**: Easy TLS public key pinning integration with common CA support
146
+ - **Advanced Proxy Detection**: Comprehensive detection of VPN, Tor, custom DNS, and MITM appliances
147
+ - **Enterprise Policy Management**: JSON-based customizable security rules and compliance validation
148
+ - **Policy Templates**: Pre-built policies for banking, enterprise, and development environments
149
+ - **Compliance Reporting**: Detailed violation tracking and audit logging
150
+ - **Network Analysis Integration**: Real-time network threat detection and assessment
151
+
152
+ ### Usage
153
+
154
+ ```ruby
155
+ # Configure enterprise policy
156
+ AiRootShield.configure_policy('examples/policies/banking_policy.json')
157
+
158
+ # Set up certificate pinning
159
+ pinning = AiRootShield.configure_certificate_pinning
160
+ pinning.add_pin('api.mybank.com', ['sha256/YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihg='])
161
+
162
+ # Configure proxy detection
163
+ AiRootShield.configure_proxy_detection
164
+
165
+ # Scan with network analysis
166
+ result = AiRootShield.scan_device_with_config('device_logs.json', {
167
+ enable_network_analysis: true,
168
+ target_ip: '192.168.1.100',
169
+ target_url: 'https://api.mybank.com'
170
+ })
171
+
172
+ puts "Compliance Status: #{result[:compliance][:compliant] ? 'COMPLIANT' : 'NON-COMPLIANT'}"
173
+ puts "Network Analysis: #{result[:network_analysis]}"
174
+ ```
175
+
176
+ ### CLI Usage
177
+
178
+ ```bash
179
+ # Scan with enterprise policy and network security
180
+ $ ai_root_shield --policy examples/policies/banking_policy.json \
181
+ --enable-cert-pinning \
182
+ --enable-proxy-detection \
183
+ --target-url https://api.mybank.com \
184
+ --verbose device_logs.json
185
+ ```
186
+
187
+ ## RASP Protection (v0.3.0)
136
188
 
137
189
  Runtime Application Self-Protection provides real-time threat detection and blocking:
138
190
 
@@ -0,0 +1,79 @@
1
+ {
2
+ "version": "1.0",
3
+ "name": "Banking Security Policy",
4
+ "description": "High-security policy for banking and financial applications",
5
+ "minimum_security_level": 95,
6
+ "compliance_rules": {
7
+ "device_requirements": {
8
+ "allow_rooted_devices": false,
9
+ "allow_jailbroken_devices": false,
10
+ "allow_emulators": false,
11
+ "require_screen_lock": true,
12
+ "minimum_os_version": {
13
+ "android": "10.0",
14
+ "ios": "14.0"
15
+ },
16
+ "require_biometric_authentication": true,
17
+ "require_device_encryption": true
18
+ },
19
+ "network_security": {
20
+ "allow_vpn": false,
21
+ "allow_proxy": false,
22
+ "allow_tor": false,
23
+ "require_certificate_pinning": true,
24
+ "allowed_dns_servers": [
25
+ "8.8.8.8",
26
+ "1.1.1.1"
27
+ ],
28
+ "blocked_dns_servers": [],
29
+ "require_tls_1_3_minimum": true,
30
+ "block_self_signed_certificates": true,
31
+ "require_hsts": true
32
+ },
33
+ "application_integrity": {
34
+ "allow_debug_builds": false,
35
+ "allow_repackaged_apps": false,
36
+ "require_code_signing": true,
37
+ "allowed_certificate_issuers": [
38
+ "Bank Certificate Authority"
39
+ ],
40
+ "require_app_store_installation": true,
41
+ "block_sideloaded_apps": true,
42
+ "require_integrity_verification": true
43
+ },
44
+ "runtime_protection": {
45
+ "enable_rasp": true,
46
+ "allow_debugging": false,
47
+ "allow_hooking_frameworks": false,
48
+ "enable_tamper_detection": true,
49
+ "enable_anti_debug": true,
50
+ "enable_memory_protection": true,
51
+ "protection_interval": 500,
52
+ "enable_screenshot_protection": true
53
+ }
54
+ },
55
+ "risk_thresholds": {
56
+ "low": 5,
57
+ "medium": 15,
58
+ "high": 30,
59
+ "critical": 50
60
+ },
61
+ "actions": {
62
+ "on_policy_violation": "immediate_block",
63
+ "on_high_risk": "immediate_block",
64
+ "on_critical_risk": "immediate_block",
65
+ "custom_actions": {
66
+ "any_security_threat": "immediate_block_and_alert"
67
+ }
68
+ },
69
+ "reporting": {
70
+ "enable_audit_logs": true,
71
+ "log_level": "info",
72
+ "retention_days": 365,
73
+ "enable_real_time_alerts": true,
74
+ "alert_endpoints": [
75
+ "https://security.bank.com/critical-alerts",
76
+ "https://soc.bank.com/mobile-threats"
77
+ ]
78
+ }
79
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "version": "1.0",
3
+ "name": "Development Environment Policy",
4
+ "description": "Relaxed policy for development and testing environments",
5
+ "minimum_security_level": 40,
6
+ "compliance_rules": {
7
+ "device_requirements": {
8
+ "allow_rooted_devices": true,
9
+ "allow_jailbroken_devices": true,
10
+ "allow_emulators": true,
11
+ "require_screen_lock": false,
12
+ "minimum_os_version": {
13
+ "android": "7.0",
14
+ "ios": "11.0"
15
+ }
16
+ },
17
+ "network_security": {
18
+ "allow_vpn": true,
19
+ "allow_proxy": true,
20
+ "allow_tor": false,
21
+ "require_certificate_pinning": false,
22
+ "allowed_dns_servers": [],
23
+ "blocked_dns_servers": [],
24
+ "require_tls_1_2_minimum": false,
25
+ "block_self_signed_certificates": false
26
+ },
27
+ "application_integrity": {
28
+ "allow_debug_builds": true,
29
+ "allow_repackaged_apps": true,
30
+ "require_code_signing": false,
31
+ "allowed_certificate_issuers": [],
32
+ "require_app_store_installation": false,
33
+ "block_sideloaded_apps": false
34
+ },
35
+ "runtime_protection": {
36
+ "enable_rasp": false,
37
+ "allow_debugging": true,
38
+ "allow_hooking_frameworks": true,
39
+ "enable_tamper_detection": false,
40
+ "enable_anti_debug": false,
41
+ "enable_memory_protection": false,
42
+ "protection_interval": 5000
43
+ }
44
+ },
45
+ "risk_thresholds": {
46
+ "low": 30,
47
+ "medium": 60,
48
+ "high": 80,
49
+ "critical": 95
50
+ },
51
+ "actions": {
52
+ "on_policy_violation": "log_only",
53
+ "on_high_risk": "log_only",
54
+ "on_critical_risk": "alert",
55
+ "custom_actions": {}
56
+ },
57
+ "reporting": {
58
+ "enable_audit_logs": true,
59
+ "log_level": "debug",
60
+ "retention_days": 30,
61
+ "enable_real_time_alerts": false,
62
+ "alert_endpoints": []
63
+ }
64
+ }
@@ -0,0 +1,89 @@
1
+ {
2
+ "version": "1.0",
3
+ "name": "Enterprise Security Policy",
4
+ "description": "Comprehensive enterprise security policy for mobile applications",
5
+ "minimum_security_level": 80,
6
+ "compliance_rules": {
7
+ "device_requirements": {
8
+ "allow_rooted_devices": false,
9
+ "allow_jailbroken_devices": false,
10
+ "allow_emulators": false,
11
+ "require_screen_lock": true,
12
+ "minimum_os_version": {
13
+ "android": "9.0",
14
+ "ios": "13.0"
15
+ },
16
+ "allowed_device_models": [],
17
+ "blocked_device_models": []
18
+ },
19
+ "network_security": {
20
+ "allow_vpn": false,
21
+ "allow_proxy": false,
22
+ "allow_tor": false,
23
+ "require_certificate_pinning": true,
24
+ "allowed_dns_servers": [
25
+ "8.8.8.8",
26
+ "8.8.4.4",
27
+ "1.1.1.1",
28
+ "1.0.0.1"
29
+ ],
30
+ "blocked_dns_servers": [
31
+ "94.140.14.14",
32
+ "76.76.19.19"
33
+ ],
34
+ "require_tls_1_2_minimum": true,
35
+ "block_self_signed_certificates": true
36
+ },
37
+ "application_integrity": {
38
+ "allow_debug_builds": false,
39
+ "allow_repackaged_apps": false,
40
+ "require_code_signing": true,
41
+ "allowed_certificate_issuers": [
42
+ "Apple Inc.",
43
+ "Google Inc.",
44
+ "Enterprise CA"
45
+ ],
46
+ "require_app_store_installation": true,
47
+ "block_sideloaded_apps": true
48
+ },
49
+ "runtime_protection": {
50
+ "enable_rasp": true,
51
+ "allow_debugging": false,
52
+ "allow_hooking_frameworks": false,
53
+ "enable_tamper_detection": true,
54
+ "enable_anti_debug": true,
55
+ "enable_memory_protection": true,
56
+ "protection_interval": 1000
57
+ }
58
+ },
59
+ "risk_thresholds": {
60
+ "low": 15,
61
+ "medium": 35,
62
+ "high": 60,
63
+ "critical": 80
64
+ },
65
+ "actions": {
66
+ "on_policy_violation": "block",
67
+ "on_high_risk": "alert_and_log",
68
+ "on_critical_risk": "block_and_alert",
69
+ "custom_actions": {
70
+ "device_rooted": "immediate_block",
71
+ "tor_detected": "immediate_block",
72
+ "debugging_detected": "immediate_block"
73
+ }
74
+ },
75
+ "reporting": {
76
+ "enable_audit_logs": true,
77
+ "log_level": "warning",
78
+ "retention_days": 180,
79
+ "enable_real_time_alerts": true,
80
+ "alert_endpoints": [
81
+ "https://security.company.com/alerts"
82
+ ]
83
+ },
84
+ "exemptions": {
85
+ "test_devices": [],
86
+ "development_environments": [],
87
+ "emergency_override_codes": []
88
+ }
89
+ }
data/exe/ai_root_shield CHANGED
@@ -19,7 +19,12 @@ class AiRootShieldCLI
19
19
  enable_network_analysis: true,
20
20
  enable_ai_behavioral_analysis: true,
21
21
  enable_rasp_protection: false,
22
- rasp_monitoring_time: 5
22
+ rasp_monitoring_time: 5,
23
+ policy_file: nil,
24
+ enable_certificate_pinning: false,
25
+ enable_proxy_detection: false,
26
+ target_ip: nil,
27
+ target_url: nil
23
28
  }
24
29
  end
25
30
 
@@ -40,6 +45,24 @@ class AiRootShieldCLI
40
45
  end
41
46
 
42
47
  begin
48
+ # Configure enterprise policy if provided
49
+ if @options[:policy_file]
50
+ puts "Loading enterprise policy from #{@options[:policy_file]}..." if @options[:verbose]
51
+ AiRootShield.configure_policy(@options[:policy_file])
52
+ end
53
+
54
+ # Configure certificate pinning if enabled
55
+ if @options[:enable_certificate_pinning]
56
+ puts "Configuring certificate pinning..." if @options[:verbose]
57
+ AiRootShield.configure_certificate_pinning
58
+ end
59
+
60
+ # Configure proxy detection if enabled
61
+ if @options[:enable_proxy_detection]
62
+ puts "Configuring proxy detection..." if @options[:verbose]
63
+ AiRootShield.configure_proxy_detection
64
+ end
65
+
43
66
  # Start RASP protection if enabled
44
67
  if @options[:enable_rasp_protection]
45
68
  puts "Starting RASP protection..." if @options[:verbose]
@@ -67,6 +90,11 @@ class AiRootShieldCLI
67
90
  result[:rasp_status] = AiRootShield.rasp_protection.protection_status
68
91
  end
69
92
 
93
+ # Add security status if verbose
94
+ if @options[:verbose]
95
+ result[:security_status] = AiRootShield.security_status
96
+ end
97
+
70
98
  output_result(result)
71
99
 
72
100
  rescue AiRootShield::Error => e
@@ -136,6 +164,26 @@ class AiRootShieldCLI
136
164
  @options[:rasp_monitoring_time] = time
137
165
  end
138
166
 
167
+ opts.on("--policy FILE", "Enterprise policy file path") do |file|
168
+ @options[:policy_file] = file
169
+ end
170
+
171
+ opts.on("--enable-cert-pinning", "Enable certificate pinning validation") do
172
+ @options[:enable_certificate_pinning] = true
173
+ end
174
+
175
+ opts.on("--enable-proxy-detection", "Enable advanced proxy detection") do
176
+ @options[:enable_proxy_detection] = true
177
+ end
178
+
179
+ opts.on("--target-ip IP", "Target IP address for network analysis") do |ip|
180
+ @options[:target_ip] = ip
181
+ end
182
+
183
+ opts.on("--target-url URL", "Target URL for certificate pinning validation") do |url|
184
+ @options[:target_url] = url
185
+ end
186
+
139
187
  opts.on("-h", "--help", "Show this help message") do
140
188
  puts opts
141
189
  exit
@@ -149,7 +197,7 @@ class AiRootShieldCLI
149
197
  end
150
198
 
151
199
  def output_result(result)
152
- case @options[:output_format]
200
+ case @options[:format]
153
201
  when "json"
154
202
  puts JSON.pretty_generate(result)
155
203
  when "text"
@@ -167,6 +215,42 @@ class AiRootShieldCLI
167
215
  puts "Version: #{result[:version]}"
168
216
  puts ""
169
217
 
218
+ # Display compliance status if available
219
+ if result[:compliance]
220
+ puts "Policy Compliance:"
221
+ puts " Status: #{result[:compliance][:compliant] ? 'COMPLIANT' : 'NON-COMPLIANT'}"
222
+ puts " Policy Version: #{result[:compliance][:policy_version]}"
223
+
224
+ if result[:compliance][:violations].any?
225
+ puts " Violations:"
226
+ result[:compliance][:violations].each do |violation|
227
+ puts " • #{violation[:message]} (#{violation[:severity]})"
228
+ end
229
+ end
230
+ puts ""
231
+ end
232
+
233
+ # Display network analysis if available
234
+ if result[:network_analysis]
235
+ puts "Network Security Analysis:"
236
+
237
+ if result[:network_analysis][:proxy_detection]
238
+ proxy = result[:network_analysis][:proxy_detection]
239
+ puts " Proxy Detection: #{proxy[:proxy_detected] ? 'DETECTED' : 'Clean'}"
240
+ if proxy[:proxy_detected]
241
+ puts " Types: #{proxy[:proxy_types].join(', ')}"
242
+ puts " Confidence: #{(proxy[:confidence_score] * 100).round}%"
243
+ end
244
+ end
245
+
246
+ if result[:network_analysis][:certificate_pinning]
247
+ pinning = result[:network_analysis][:certificate_pinning]
248
+ puts " Certificate Pinning: #{pinning[:valid] ? 'VALID' : 'FAILED'}"
249
+ puts " Reason: #{pinning[:reason]}" unless pinning[:valid]
250
+ end
251
+ puts ""
252
+ end
253
+
170
254
  if result[:factors].any?
171
255
  puts "Detected Security Factors:"
172
256
  result[:factors].each do |factor|
@@ -184,6 +268,15 @@ class AiRootShieldCLI
184
268
  else
185
269
  puts "No security threats detected."
186
270
  end
271
+
272
+ # Display RASP status if available
273
+ if result[:rasp_status]
274
+ puts ""
275
+ puts "RASP Protection Status:"
276
+ puts " Active: #{result[:rasp_status][:active] ? 'YES' : 'NO'}"
277
+ puts " Events Detected: #{result[:rasp_status][:events_detected] || 0}"
278
+ puts " Protection Level: #{result[:rasp_status][:protection_level] || 'Standard'}"
279
+ end
187
280
  end
188
281
 
189
282
  def output_summary_format(result)