Spaces:
Runtime error
Runtime error
File size: 14,497 Bytes
c44d66d |
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 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"source": [
"TEST = 1\n",
"test = 2\n",
"print(TEST)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8c:7a:aa:f2:e5:88\n"
]
}
],
"source": [
"from getmac import get_mac_address as gma\n",
"print(gma())"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Linhs-MacBook-Air-2.local\n"
]
}
],
"source": [
"import platform\n",
"print(platform.node())"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Apple, Inc.'"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"from getmac import get_mac_address as gma\n",
"mac_address = gma()\n",
"\n",
"def get_mac_details(mac_address):\n",
" \n",
" # We will use an API to get the vendor details\n",
" url = \"https://api.macvendors.com/\"\n",
" \n",
" # Use get method to fetch details\n",
" response = requests.get(url+mac_address)\n",
" if response.status_code != 200:\n",
" raise Exception(\"[!] Invalid MAC Address!\")\n",
" return response.content.decode()\n",
"\n",
"get_mac_details(mac_address)"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"24291951679257\n"
]
},
{
"data": {
"text/plain": [
"UUID('00000000-0000-0000-0000-1617e9269719')"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import uuid\n",
"import hashlib\n",
"uuid_1 = c\n",
"print(uuid_1)\n",
"uuid.UUID(int=uuid.getnode())\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'int' object has no attribute 'encode'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn [72], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m hashlib\u001b[38;5;241m.\u001b[39mmd5(\u001b[43muuid\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgetnode\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencode\u001b[49m())\u001b[38;5;241m.\u001b[39mhexdigest()\n",
"\u001b[0;31mAttributeError\u001b[0m: 'int' object has no attribute 'encode'"
]
}
],
"source": [
"hashlib.md5(uuid.getnode().encode()).hexdigest()"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {},
"outputs": [],
"source": [
"import psutil\n",
"import platform\n",
"from datetime import datetime"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"======================================== System Information ========================================\n",
"System: Darwin\n",
"Node Name: Linhs-MacBook-Air-2.local\n",
"Release: 21.6.0\n",
"Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:35 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T8101\n",
"Machine: arm64\n",
"Processor: arm\n"
]
}
],
"source": [
"print(\"=\"*40, \"System Information\", \"=\"*40)\n",
"uname = platform.uname()\n",
"print(f\"System: {uname.system}\")\n",
"print(f\"Node Name: {uname.node}\")\n",
"print(f\"Release: {uname.release}\")\n",
"print(f\"Version: {uname.version}\")\n",
"print(f\"Machine: {uname.machine}\")\n",
"print(f\"Processor: {uname.processor}\")"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'system': 'Darwin',\n",
" 'platform-release': '21.6.0',\n",
" 'platform-version': 'Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:35 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T8101',\n",
" 'architecture': 'arm64',\n",
" 'hostname': 'Linhs-MacBook-Air-2.local',\n",
" 'platform': 'macOS-12.5.1-arm64-arm-64bit',\n",
" 'ip-address': '192.168.1.8',\n",
" 'mac-address': '16:17:e9:26:97:19',\n",
" 'processor': 'arm',\n",
" 'ram': '16 GB'}"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import platform,socket,re,uuid,json,psutil,logging\n",
"\n",
"def getSystemInfo():\n",
" try:\n",
" info={}\n",
" info['system']=platform.system()\n",
" info['platform-release']=platform.release()\n",
" info['platform-version']=platform.version()\n",
" info['architecture']=platform.machine()\n",
" info['hostname']=socket.gethostname()\n",
" info['platform'] = platform.platform()\n",
" info['ip-address']=socket.gethostbyname(socket.gethostname())\n",
" info['mac-address']=':'.join(re.findall('..', '%012x' % uuid.getnode()))\n",
" info['processor']=platform.processor()\n",
" info['ram']=str(round(psutil.virtual_memory().total / (1024.0 **3)))+\" GB\"\n",
" return json.dumps(info)\n",
" except Exception as e:\n",
" logging.exception(e)\n",
"\n",
"json.loads(getSystemInfo())"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2001:ee0:4f84:6a70:652e:732d:859a:76e9\n"
]
}
],
"source": [
"import urllib.request\n",
"\n",
"external_ip = urllib.request.urlopen('https://ident.me').read().decode('utf8')\n",
"\n",
"print(external_ip)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"123.21.79.245\n",
"My public IP address is: 123.21.79.245\n"
]
}
],
"source": [
"from requests import get\n",
"ip_v4 = get('https://api.ipify.org').content.decode('utf8')\n",
"print(ip_v4)\n",
"print('My public IP address is: {}'.format(ip_v4))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'123.21.79.245'"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ip_v4"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'2001:ee0:4f84:6a70:1897:c02c:2c98:6d33'"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"url = \"https://ident.me\"\n",
"\n",
"# Use get method to fetch details\n",
"ipv6 = requests.get(url)\n",
"\n",
"ipv6.content.decode()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'ip': '123.21.79.245', 'security': {'vpn': False, 'proxy': False, 'tor': False, 'relay': False}, 'location': {'city': 'Ho Chi Minh City', 'region': 'Ho Chi Minh', 'country': 'Vietnam', 'continent': 'Asia', 'region_code': 'SG', 'country_code': 'VN', 'continent_code': 'AS', 'latitude': '10.8326', 'longitude': '106.6581', 'time_zone': 'Asia/Ho_Chi_Minh', 'locale_code': 'en', 'metro_code': '', 'is_in_european_union': False}, 'network': {'network': '123.16.0.0/13', 'autonomous_system_number': 'AS45899', 'autonomous_system_organization': 'VNPT Corp'}}\n",
"{'vpn': False, 'proxy': False, 'tor': False, 'relay': False}\n"
]
}
],
"source": [
"import json\n",
"API_key = \"bc2fe06e10244a0797ceffc6b4ce4a09\"\n",
"response = requests.get(\"https://vpnapi.io/api/\" + ip_v4 + \"?key=\" + API_key)\n",
"data = json.loads(response.text)\n",
"print(data) # Outputs everything\n",
"print(data[\"security\"]) # Outputs just the security details"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'message': 'Invalid API key.'}"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# isp[\"status\"]\n",
"isp"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[10.823, 106.6296]\n"
]
}
],
"source": [
"import geocoder\n",
"g = geocoder.ip('me')\n",
"print(g.latlng)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CHC, Gosainganj, Sultanpur Road, गोसाईगंज, Lucknow, Uttar Pradesh, 227125, India\n",
"Latitude = 26.7652312 \n",
"\n",
"Longitude = 81.1196719\n"
]
}
],
"source": [
"# importing geopy library\n",
"from geopy.geocoders import Nominatim\n",
" \n",
"# calling the Nominatim tool\n",
"loc = Nominatim(user_agent=\"GetLoc\")\n",
" \n",
"# entering the location name\n",
"getLoc = loc.geocode(\"Gosainganj Lucknow\")\n",
" \n",
"# printing address\n",
"print(getLoc.address)\n",
" \n",
"# printing latitude and longitude\n",
"print(\"Latitude = \", getLoc.latitude, \"\\n\")\n",
"print(\"Longitude = \", getLoc.longitude)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name '__file__' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn [1], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mos\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m# Set direction as current folder\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m sourceFileDir \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mdirname(os\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mabspath(\u001b[38;5;18;43m__file__\u001b[39;49m))\n\u001b[1;32m 4\u001b[0m os\u001b[38;5;241m.\u001b[39mchdir(sourceFileDir)\n",
"\u001b[0;31mNameError\u001b[0m: name '__file__' is not defined"
]
}
],
"source": [
"import os\n",
"# Set direction as current folder\n",
"sourceFileDir = os.path.dirname(os.path.abspath(__file__))\n",
"os.chdir(sourceFileDir)\n"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Days: 0\n",
"Microseconds: 854282\n",
"seconds: 93\n",
"Max: 999999999 days, 23:59:59.999999\n",
"Min: -999999999 days, 0:00:00\n",
"Resolution: 0:00:00.000001\n",
"Total Seconds: 93.854282\n"
]
}
],
"source": [
"# Import libraries\n",
"import os\n",
"import streamlit as st\n",
"from PIL import Image\n",
"from streamlit_extras.switch_page_button import switch_page\n",
"from bokeh.models.widgets import Button\n",
"from bokeh.models import CustomJS\n",
"from streamlit_bokeh_events import streamlit_bokeh_events\n",
"from datetime import timedelta\n",
"from datetime import datetime\n",
"# Stop counting time after the user finished entering username, password and clicked login button\n",
"d1 = datetime.now()\n",
"\n",
"\n",
"d2 = datetime(year=2022, month=9, day=26, hour=0, minute=40)\n",
"\n",
"# Get timedelta by subtracting two dates\n",
"td = d2 - d1\n",
"\n",
"# access timedelta attributes\n",
"print(\"Days:\", td.days)\n",
"print(\"Microseconds:\", td.microseconds)\n",
"print(\"seconds:\", td.seconds)\n",
"print(\"Max:\", td.max)\n",
"print(\"Min:\", td.min)\n",
"print(\"Resolution:\", td.resolution)\n",
"print(\"Total Seconds:\", td.total_seconds())"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1664128185.102907"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import time\n",
"time.time()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.6 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|