{ "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 }