Spaces:
Sleeping
Sleeping
Download src/streamlit_app.py from PryvX/Law-Enforcement-Data-Analysis: direct link, hf CLI and curl.
- Browser
- Download file 3.34 kB
-
https://huggingface.co/spaces/PryvX/Law-Enforcement-Data-Analysis/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/PryvX/Law-Enforcement-Data-Analysis/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/PryvX/Law-Enforcement-Data-Analysis/resolve/main/src/streamlit_app.py
3.34 kB
| import streamlit as st | |
| import base64 | |
| import random | |
| import json | |
| from datetime import datetime | |
| # ------------------------- | |
| # Utility Functions | |
| # ------------------------- | |
| def encrypt_input(value: str) -> str: | |
| """Simple Base64 encoding for demo encryption.""" | |
| return base64.b64encode(value.encode()).decode() | |
| def dummy_federated_query(msisdn: str): | |
| return { | |
| "msisdn": msisdn, | |
| "encrypted_msisdn": encrypt_input(msisdn), | |
| "top_location": "Jakarta", | |
| "top_domain": "facebook.com", | |
| "timestamps": ["2025-09-01 08:15", "2025-09-01 09:45"] | |
| } | |
| def dummy_imsi_catcher(imsi: str): | |
| return { | |
| "imsi": imsi, | |
| "encrypted_imsi": encrypt_input(imsi), | |
| "detected": True, | |
| "message": "Possible fake BTS detected near Bandung", | |
| "timeline": [ | |
| { | |
| "receivedAt": "2025-09-01 10:12", | |
| "locationName": "Bandung", | |
| "technology": "4G", | |
| "ulRssi": -85, | |
| "dlRssi": -90, | |
| "distance": "500 meters" | |
| }, | |
| { | |
| "receivedAt": "2025-09-01 11:30", | |
| "locationName": "Bandung", | |
| "technology": "5G", | |
| "ulRssi": -70, | |
| "dlRssi": -80, | |
| "distance": "300 meters" | |
| } | |
| ] | |
| } | |
| def dummy_identity_lookup(msisdn: str): | |
| return { | |
| "msisdn": msisdn, | |
| "encrypted_msisdn": encrypt_input(msisdn), | |
| "found": True, | |
| "results": [ | |
| {"name": "John Doe", "platform": "Facebook", "profile": "facebook.com/john.doe"}, | |
| {"name": "J. D.", "platform": "LinkedIn", "profile": "linkedin.com/in/johnd"} | |
| ] | |
| } | |
| # ------------------------- | |
| # Streamlit App | |
| # ------------------------- | |
| st.set_page_config(page_title="Federated Data Analysis (Demo)", layout="wide") | |
| st.title("๐ฎโโ๏ธ Law Enforcement Federated Data Analysis (Demo)") | |
| # st.image("lea.png", caption="Demo Image", width=600) | |
| st.write("This is a dummy demo app showing how federated data collaboration works for MSISDN/IMSI intelligence.") | |
| # Sidebar - Node Management | |
| st.sidebar.header("โ๏ธ Node Registration") | |
| registered_nodes = st.sidebar.multiselect( | |
| "Select Active Nodes:", | |
| ["Location Node", "Browsing Node", "Social Node", "IMSI Detection Node"], | |
| default=["Location Node", "Browsing Node"] | |
| ) | |
| # Case Selection | |
| case = st.radio( | |
| "Select Analysis Case:", | |
| options=[1, 2, 3], | |
| format_func=lambda x: { | |
| 1: "Federated Query (Location + Browsing)", | |
| 2: "IMSI Catcher Detection", | |
| 3: "Identity Lookup" | |
| }[x] | |
| ) | |
| # Input Field | |
| user_input = "" | |
| if case in [1, 3]: | |
| user_input = st.text_input("Enter MSISDN", "6281234567890") | |
| elif case == 2: | |
| user_input = st.text_input("Enter IMSI", "510103421502760") | |
| # Run Button | |
| if st.button("๐ Run Analysis"): | |
| if case == 1: | |
| result = dummy_federated_query(user_input) | |
| elif case == 2: | |
| result = dummy_imsi_catcher(user_input) | |
| elif case == 3: | |
| result = dummy_identity_lookup(user_input) | |
| else: | |
| result = {"error": "Invalid case"} | |
| st.subheader("๐ Encrypted Request Sent") | |
| st.code(result.get("encrypted_msisdn", result.get("encrypted_imsi", "N/A"))) | |
| st.subheader("๐ก Analysis Result") | |
| st.json(result) |