Update app.py
Browse files
app.py
CHANGED
|
@@ -3,22 +3,17 @@ import base64
|
|
| 3 |
import json
|
| 4 |
import re
|
| 5 |
import html
|
| 6 |
-
from typing import Dict, List, Any
|
| 7 |
import pandas as pd
|
| 8 |
|
| 9 |
# Set page configuration
|
| 10 |
st.set_page_config(
|
| 11 |
page_title="Proxy Server Decoder",
|
| 12 |
page_icon="π",
|
| 13 |
-
layout="wide"
|
| 14 |
-
initial_sidebar_state="expanded"
|
| 15 |
)
|
| 16 |
|
| 17 |
class ProxyServerDecoder:
|
| 18 |
-
def
|
| 19 |
-
self.results = []
|
| 20 |
-
|
| 21 |
-
def decode_proxy_entry(self, encoded_str: str) -> Dict[str, Any]:
|
| 22 |
"""Decode a single proxy entry from base64 -> hex -> JSON"""
|
| 23 |
try:
|
| 24 |
# Add padding if needed
|
|
@@ -46,7 +41,7 @@ class ProxyServerDecoder:
|
|
| 46 |
"original_length": len(encoded_str)
|
| 47 |
}
|
| 48 |
|
| 49 |
-
def extract_entries_from_html(self, html_content
|
| 50 |
"""Extract base64 entries from HTML data-ss attribute"""
|
| 51 |
try:
|
| 52 |
unescaped_html = html.unescape(html_content)
|
|
@@ -77,7 +72,7 @@ class ProxyServerDecoder:
|
|
| 77 |
st.error(f"Error extracting from HTML: {e}")
|
| 78 |
return []
|
| 79 |
|
| 80 |
-
def process_html(self, html_content
|
| 81 |
"""Process HTML content and decode all entries"""
|
| 82 |
entries = self.extract_entries_from_html(html_content)
|
| 83 |
|
|
@@ -113,30 +108,12 @@ class ProxyServerDecoder:
|
|
| 113 |
},
|
| 114 |
"results": results
|
| 115 |
}
|
| 116 |
-
|
| 117 |
-
def process_single_entry(self, encoded_string: str) -> Dict[str, Any]:
|
| 118 |
-
"""Process a single encoded string"""
|
| 119 |
-
return self.decode_proxy_entry(encoded_string)
|
| 120 |
|
| 121 |
def main():
|
| 122 |
-
# Initialize decoder
|
| 123 |
decoder = ProxyServerDecoder()
|
| 124 |
|
| 125 |
-
|
| 126 |
-
st.
|
| 127 |
-
st.sidebar.markdown("""
|
| 128 |
-
Decode base64-encoded proxy server information from HTML script tags.
|
| 129 |
-
|
| 130 |
-
### How to use:
|
| 131 |
-
1. **Single Entry**: Paste a base64 string
|
| 132 |
-
2. **HTML Parser**: Paste HTML with data-ss attribute
|
| 133 |
-
3. View decoded results in tables and JSON
|
| 134 |
-
|
| 135 |
-
### Input Format:
|
| 136 |
-
```html
|
| 137 |
-
<script data-ss="["BASE64_STRING",...]"></script>
|
| 138 |
-
```
|
| 139 |
-
""")
|
| 140 |
|
| 141 |
# Sample data
|
| 142 |
sample_html = '''<script
|
|
@@ -146,175 +123,92 @@ def main():
|
|
| 146 |
data-ss="["N2IyMjY5NjQyMjNhMzIzMDMxMmMyMjc1NzI2YzIyM2EyMjY4NzQ3NDcwNzMzYTVjMmY1YzJmMzEzMDM4MmUzMTM4MzEyZTMxMzEyZTMxMzczMTVjMmY1ZjVmNjM3MDMyMmU3MDY4NzAyMjJjMjI2ZTYxNmQ2NTIyM2EyMjcwNzM3OTYzNjg3YTRjNmY3MzQxNmU2NzY1NmM2NTczMzI0ZDIyN2Q=","N2IyMjY5NjQyMjNhMzEzODM1MmMyMjc1NzI2YzIyM2EyMjY4NzQ3NDcwNzMzYTVjMmY1YzJmMzkzNTJlMzIzMTM0MmUzNTMzMmUzNDM4NWMyZjVmNWY2MzcwMzIyZTcwNjg3MDIyMmMyMjZlNjE2ZDY1MjIzYTIyNmQ2NTc2NTM3MDYxNjM2NTU3NjE3MjczNjE3NzUwMjI3ZA=="]"
|
| 147 |
></script>'''
|
| 148 |
|
| 149 |
-
#
|
| 150 |
-
st.
|
| 151 |
-
|
| 152 |
-
# Tabs for different functionality
|
| 153 |
-
tab1, tab2, tab3 = st.tabs(["π HTML Parser", "π€ Single Entry", "π Results"])
|
| 154 |
|
| 155 |
with tab1:
|
| 156 |
st.header("HTML Content Parser")
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
height=300,
|
| 165 |
-
placeholder="Paste HTML with data-ss attribute here..."
|
| 166 |
-
)
|
| 167 |
-
|
| 168 |
-
with col2:
|
| 169 |
-
st.markdown("### Quick Actions")
|
| 170 |
-
if st.button("π Use Sample Data", use_container_width=True):
|
| 171 |
-
st.session_state.sample_used = True
|
| 172 |
-
|
| 173 |
-
if st.button("ποΈ Clear Input", use_container_width=True):
|
| 174 |
-
html_input = ""
|
| 175 |
-
st.rerun()
|
| 176 |
-
|
| 177 |
-
st.markdown("---")
|
| 178 |
-
st.markdown("""
|
| 179 |
-
**Expected Format:**
|
| 180 |
-
```html
|
| 181 |
-
<script data-ss="["base64_str1","base64_str2"]">
|
| 182 |
-
```
|
| 183 |
-
""")
|
| 184 |
|
| 185 |
-
if st.button("π Parse HTML", type="primary"
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
else:
|
| 193 |
-
st.
|
| 194 |
|
| 195 |
with tab2:
|
| 196 |
st.header("Single Entry Decoder")
|
| 197 |
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
placeholder="Paste your base64 string here..."
|
| 205 |
-
)
|
| 206 |
-
|
| 207 |
-
with col2:
|
| 208 |
-
st.markdown("### Example")
|
| 209 |
-
st.code("N2IyMjY5NjQyMjNhMz...", language="text")
|
| 210 |
|
| 211 |
-
if st.button("π Decode Single Entry", type="primary"
|
| 212 |
if single_input.strip():
|
| 213 |
with st.spinner("Decoding entry..."):
|
| 214 |
-
result = decoder.
|
| 215 |
-
st.session_state.single_result = result
|
| 216 |
|
| 217 |
if result["status"] == "success":
|
| 218 |
st.success("β
Entry decoded successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
else:
|
| 220 |
st.error(f"β {result.get('error', 'Decoding failed')}")
|
| 221 |
else:
|
| 222 |
-
st.warning("
|
| 223 |
-
|
| 224 |
-
with tab3:
|
| 225 |
-
st.header("Decoding Results")
|
| 226 |
-
|
| 227 |
-
# HTML Results
|
| 228 |
-
if 'html_result' in st.session_state:
|
| 229 |
-
result = st.session_state.html_result
|
| 230 |
-
|
| 231 |
-
if result["status"] == "success":
|
| 232 |
-
# Statistics
|
| 233 |
-
stats = result["statistics"]
|
| 234 |
-
col1, col2, col3, col4 = st.columns(4)
|
| 235 |
-
|
| 236 |
-
with col1:
|
| 237 |
-
st.metric("Total Entries", stats["total_entries"])
|
| 238 |
-
with col2:
|
| 239 |
-
st.metric("Successful", stats["successful_decodes"])
|
| 240 |
-
with col3:
|
| 241 |
-
st.metric("Failed", stats["failed_decodes"])
|
| 242 |
-
with col4:
|
| 243 |
-
st.metric("Success Rate", stats["success_rate"])
|
| 244 |
-
|
| 245 |
-
# Results table
|
| 246 |
-
st.subheader("Decoded Entries")
|
| 247 |
-
|
| 248 |
-
# Prepare data for table
|
| 249 |
-
table_data = []
|
| 250 |
-
for entry in result["results"]:
|
| 251 |
-
row = {
|
| 252 |
-
"Entry #": entry["entry_number"],
|
| 253 |
-
"Status": "β
Success" if entry["status"] == "success" else "β Failed",
|
| 254 |
-
"Preview": entry["encoded_preview"],
|
| 255 |
-
"Length": entry["original_length"]
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
if entry["status"] == "success":
|
| 259 |
-
decoded = entry["decoded_data"]
|
| 260 |
-
# Add decoded fields to row
|
| 261 |
-
for key, value in decoded.items():
|
| 262 |
-
row[key] = str(value)[:50] + "..." if len(str(value)) > 50 else str(value)
|
| 263 |
-
|
| 264 |
-
table_data.append(row)
|
| 265 |
-
|
| 266 |
-
# Display as dataframe
|
| 267 |
-
if table_data:
|
| 268 |
-
df = pd.DataFrame(table_data)
|
| 269 |
-
st.dataframe(df, use_container_width=True)
|
| 270 |
-
|
| 271 |
-
# Detailed view
|
| 272 |
-
st.subheader("Detailed Results")
|
| 273 |
-
for entry in result["results"]:
|
| 274 |
-
with st.expander(f"Entry #{entry['entry_number']} - {entry['encoded_preview']}"):
|
| 275 |
-
if entry["status"] == "success":
|
| 276 |
-
st.json(entry["decoded_data"])
|
| 277 |
-
else:
|
| 278 |
-
st.error(entry["error"])
|
| 279 |
-
|
| 280 |
-
# Download results
|
| 281 |
-
st.subheader("Export Results")
|
| 282 |
-
json_str = json.dumps(result, indent=2)
|
| 283 |
-
st.download_button(
|
| 284 |
-
label="π₯ Download JSON Results",
|
| 285 |
-
data=json_str,
|
| 286 |
-
file_name="decoded_results.json",
|
| 287 |
-
mime="application/json",
|
| 288 |
-
use_container_width=True
|
| 289 |
-
)
|
| 290 |
-
|
| 291 |
-
# Single Entry Results
|
| 292 |
-
elif 'single_result' in st.session_state:
|
| 293 |
-
result = st.session_state.single_result
|
| 294 |
-
|
| 295 |
-
if result["status"] == "success":
|
| 296 |
-
st.success("β
Decoding Successful!")
|
| 297 |
-
st.json(result["decoded_data"])
|
| 298 |
-
|
| 299 |
-
# Download single result
|
| 300 |
-
json_str = json.dumps(result["decoded_data"], indent=2)
|
| 301 |
-
st.download_button(
|
| 302 |
-
label="π₯ Download Decoded Data",
|
| 303 |
-
data=json_str,
|
| 304 |
-
file_name="single_decoded.json",
|
| 305 |
-
mime="application/json"
|
| 306 |
-
)
|
| 307 |
-
else:
|
| 308 |
-
st.error(f"β Decoding Failed: {result['error']}")
|
| 309 |
-
|
| 310 |
-
else:
|
| 311 |
-
st.info("π Process some data in the other tabs to see results here!")
|
| 312 |
-
|
| 313 |
-
# Footer
|
| 314 |
-
st.markdown("---")
|
| 315 |
-
st.markdown(
|
| 316 |
-
"**Proxy Server Decoder** β’ Decodes base64 β hex β JSON proxy information"
|
| 317 |
-
)
|
| 318 |
|
| 319 |
if __name__ == "__main__":
|
| 320 |
main()
|
|
|
|
| 3 |
import json
|
| 4 |
import re
|
| 5 |
import html
|
|
|
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
# Set page configuration
|
| 9 |
st.set_page_config(
|
| 10 |
page_title="Proxy Server Decoder",
|
| 11 |
page_icon="π",
|
| 12 |
+
layout="wide"
|
|
|
|
| 13 |
)
|
| 14 |
|
| 15 |
class ProxyServerDecoder:
|
| 16 |
+
def decode_proxy_entry(self, encoded_str):
|
|
|
|
|
|
|
|
|
|
| 17 |
"""Decode a single proxy entry from base64 -> hex -> JSON"""
|
| 18 |
try:
|
| 19 |
# Add padding if needed
|
|
|
|
| 41 |
"original_length": len(encoded_str)
|
| 42 |
}
|
| 43 |
|
| 44 |
+
def extract_entries_from_html(self, html_content):
|
| 45 |
"""Extract base64 entries from HTML data-ss attribute"""
|
| 46 |
try:
|
| 47 |
unescaped_html = html.unescape(html_content)
|
|
|
|
| 72 |
st.error(f"Error extracting from HTML: {e}")
|
| 73 |
return []
|
| 74 |
|
| 75 |
+
def process_html(self, html_content):
|
| 76 |
"""Process HTML content and decode all entries"""
|
| 77 |
entries = self.extract_entries_from_html(html_content)
|
| 78 |
|
|
|
|
| 108 |
},
|
| 109 |
"results": results
|
| 110 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
def main():
|
|
|
|
| 113 |
decoder = ProxyServerDecoder()
|
| 114 |
|
| 115 |
+
st.title("π Proxy Server Decoder")
|
| 116 |
+
st.markdown("Decode base64-encoded proxy server information from HTML script tags")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
# Sample data
|
| 119 |
sample_html = '''<script
|
|
|
|
| 123 |
data-ss="["N2IyMjY5NjQyMjNhMzIzMDMxMmMyMjc1NzI2YzIyM2EyMjY4NzQ3NDcwNzMzYTVjMmY1YzJmMzEzMDM4MmUzMTM4MzEyZTMxMzEyZTMxMzczMTVjMmY1ZjVmNjM3MDMyMmU3MDY4NzAyMjJjMjI2ZTYxNmQ2NTIyM2EyMjcwNzM3OTYzNjg3YTRjNmY3MzQxNmU2NzY1NmM2NTczMzI0ZDIyN2Q=","N2IyMjY5NjQyMjNhMzEzODM1MmMyMjc1NzI2YzIyM2EyMjY4NzQ3NDcwNzMzYTVjMmY1YzJmMzkzNTJlMzIzMTM0MmUzNTMzMmUzNDM4NWMyZjVmNWY2MzcwMzIyZTcwNjg3MDIyMmMyMjZlNjE2ZDY1MjIzYTIyNmQ2NTc2NTM3MDYxNjM2NTU3NjE3MjczNjE3NzUwMjI3ZA=="]"
|
| 124 |
></script>'''
|
| 125 |
|
| 126 |
+
# Tabs
|
| 127 |
+
tab1, tab2 = st.tabs(["π HTML Parser", "π€ Single Entry"])
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
with tab1:
|
| 130 |
st.header("HTML Content Parser")
|
| 131 |
|
| 132 |
+
html_input = st.text_area(
|
| 133 |
+
"Paste your HTML content with data-ss attribute:",
|
| 134 |
+
value=sample_html,
|
| 135 |
+
height=300,
|
| 136 |
+
help="Paste the entire HTML script tag containing data-ss attribute"
|
| 137 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
+
if st.button("π Parse HTML", type="primary"):
|
| 140 |
+
if html_input.strip():
|
| 141 |
+
with st.spinner("Processing HTML content..."):
|
| 142 |
+
result = decoder.process_html(html_input)
|
| 143 |
+
|
| 144 |
+
if result["status"] == "success":
|
| 145 |
+
st.success(f"β
Processed {result['statistics']['total_entries']} entries!")
|
| 146 |
+
|
| 147 |
+
# Display statistics
|
| 148 |
+
stats = result["statistics"]
|
| 149 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 150 |
+
with col1:
|
| 151 |
+
st.metric("Total Entries", stats["total_entries"])
|
| 152 |
+
with col2:
|
| 153 |
+
st.metric("Successful", stats["successful_decodes"])
|
| 154 |
+
with col3:
|
| 155 |
+
st.metric("Failed", stats["failed_decodes"])
|
| 156 |
+
with col4:
|
| 157 |
+
st.metric("Success Rate", stats["success_rate"])
|
| 158 |
+
|
| 159 |
+
# Display results in expandable sections
|
| 160 |
+
st.subheader("Decoded Results")
|
| 161 |
+
for entry in result["results"]:
|
| 162 |
+
with st.expander(f"Entry #{entry['entry_number']} - {entry['encoded_preview']}"):
|
| 163 |
+
if entry["status"] == "success":
|
| 164 |
+
st.json(entry["decoded_data"])
|
| 165 |
+
else:
|
| 166 |
+
st.error(f"Error: {entry['error']}")
|
| 167 |
+
|
| 168 |
+
# Download button
|
| 169 |
+
json_str = json.dumps(result, indent=2)
|
| 170 |
+
st.download_button(
|
| 171 |
+
label="π₯ Download Results as JSON",
|
| 172 |
+
data=json_str,
|
| 173 |
+
file_name="decoded_results.json",
|
| 174 |
+
mime="application/json"
|
| 175 |
+
)
|
| 176 |
+
else:
|
| 177 |
+
st.error(f"β {result.get('message', 'Processing failed')}")
|
| 178 |
else:
|
| 179 |
+
st.warning("Please enter HTML content")
|
| 180 |
|
| 181 |
with tab2:
|
| 182 |
st.header("Single Entry Decoder")
|
| 183 |
|
| 184 |
+
single_input = st.text_area(
|
| 185 |
+
"Enter base64 encoded string:",
|
| 186 |
+
height=150,
|
| 187 |
+
placeholder="Paste your base64 string here...",
|
| 188 |
+
help="Enter a single base64 encoded proxy entry"
|
| 189 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
+
if st.button("π Decode Single Entry", type="primary"):
|
| 192 |
if single_input.strip():
|
| 193 |
with st.spinner("Decoding entry..."):
|
| 194 |
+
result = decoder.decode_proxy_entry(single_input.strip())
|
|
|
|
| 195 |
|
| 196 |
if result["status"] == "success":
|
| 197 |
st.success("β
Entry decoded successfully!")
|
| 198 |
+
st.json(result["decoded_data"])
|
| 199 |
+
|
| 200 |
+
# Download single result
|
| 201 |
+
json_str = json.dumps(result["decoded_data"], indent=2)
|
| 202 |
+
st.download_button(
|
| 203 |
+
label="π₯ Download Decoded Data",
|
| 204 |
+
data=json_str,
|
| 205 |
+
file_name="single_decoded.json",
|
| 206 |
+
mime="application/json"
|
| 207 |
+
)
|
| 208 |
else:
|
| 209 |
st.error(f"β {result.get('error', 'Decoding failed')}")
|
| 210 |
else:
|
| 211 |
+
st.warning("Please enter a base64 string")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
if __name__ == "__main__":
|
| 214 |
main()
|