A Python script that connects to a WebSocket server to collect lightning strike data and outputs it in various formats (console log, Excel file, or Google Sheet).
- Real-time lightning data collection via WebSocket
- Multiple output modes:
- Log Mode: Display data in the console
- Excel Mode: Save data to a local Excel file
- Google Sheet Mode: Upload data to a Google Spreadsheet
- Color-coded console output for better readability
- Asynchronous data fetching for efficient performance
- Python 3.7+
- Google API credentials (for Google Sheet mode)
- Required Python packages (listed in requirements.txt)
-
Clone the repository:
git clone https://github.com/Manushya-a/Lightening_Data_Exfilteration.git cd Lightning_Data_Exfilteration -
Install the required packages:
pip3 install -r requirements.txt
-
For Google Sheet mode:
- For an elaborate explaination of steps head on to GSheet.md, which will provide a comprehensive stepwise guide.
python3 main.py [mode] [number]-log: Output data to console-excel: Save data to Excel file-gsheet: Upload data to Google Sheet
number: Number of lightning strike events to collect
-
Display 10 lightning strikes in console:
python3 main.py -log 10
-
Save 5 lightning strikes to Excel:
python3 main.py -excel 5
-
Upload 20 lightning strikes to Google Sheet:
python3 main.py -gsheet 20
For Google Sheet mode, you need to:
- Replace
"Link-to-your-google-spreadsheet"in the code with your actual Google Sheet ID (Line no. 132) - Ensure your
credentials.jsonfile is in the project directory - Ensure you input the target's websocket url (Line no. 184)
The collected data includes:
- Latitude and longitude of strike
- Date and time
- Station information
- Altitude
- MDS (Maximum Detection Sensitivity)
- MCG (Maximum Cloud-to-Ground)
- Region
- Delay
The main components of the code are:
-
Color Definitions (
bcolorsclass):- Provides colored console output using ANSI escape codes
-
Data Processing Functions:
flatten(): Converts JSON objects to list formattime_formater(): Converts Unix timestamp to readable formatdecode(): Decodes the WebSocket message data
-
Output Modes:
log_mode(): Prints data to consoleexcel_mode(): Saves data to Excel filegsheet_mode(): Uploads data to Google Sheet
-
Core Functions:
fetch_data(): Asynchronously collects data from WebSocketmain(): Handles command-line arguments and execution flow
Listed in requirements.txt
- Fork the repository
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
- Time formatting in Excel output may need adjustment
- Google Sheet mode has rate limits (0.75s delay between updates)
For questions or issues, please open an issue in the GitHub repository.
This project was developed only for educational purposes and demonstrates WebSocket communication, async programming, and data processing in Python.