()
| 1746 | |
| 1747 | |
| 1748 | def main(): |
| 1749 | global results_folder |
| 1750 | parser = argparse.ArgumentParser(description="Download specific or all file types from a webpage.") |
| 1751 | parser.add_argument('-u', '--url', nargs='+', |
| 1752 | help="Base URL(s), IP address(es), or IP range(s) to scrape files from") |
| 1753 | parser.add_argument('-t', '--types', |
| 1754 | help="Comma-separated list of file extensions (e.g., pdf,jpg,png) or '*' for all files") |
| 1755 | parser.add_argument('-n', '--num', type=int, default=10, |
| 1756 | help="Number of files to download (ignored if '-t *' is used)") |
| 1757 | parser.add_argument('-o', '--output', help="Directory to save downloaded files") |
| 1758 | parser.add_argument('-m', '--mode', |
| 1759 | help="Test mode: specify test case(s) (e.g., lsb,hist) or 'all' to run all tests") |
| 1760 | parser.add_argument('-l', '--local', help="Path to a local file or directory to copy into the output directory") |
| 1761 | parser.add_argument('--max_depth', type=int, default=1, help="Maximum depth of the crawl (default is 1)") |
| 1762 | args = parser.parse_args() |
| 1763 | |
| 1764 | # Make sure all tools are installed here |
| 1765 | if platform.system() == "Windows": |
| 1766 | return |
| 1767 | |
| 1768 | elif platform.system() == "Linux": |
| 1769 | print("Installing tools on Linux...") |
| 1770 | install_commands = [ |
| 1771 | "sudo apt update -y > /dev/null 2>&1", |
| 1772 | "sudo apt install -y stegdetect ruby binwalk exiftool steganography stego-rat stegosuite john > /dev/null 2>&1", |
| 1773 | "sudo gem install zsteg stegseek > /dev/null 2>&1" |
| 1774 | ] |
| 1775 | for command in install_commands: |
| 1776 | result = run_silent_command(command) |
| 1777 | if result: |
| 1778 | prGreen(f"Success: {command}") |
| 1779 | else: |
| 1780 | prRed(f"Failure: {command}") |
| 1781 | check_and_install_poppler() |
| 1782 | # print("All tools installed successfully on Linux!") |
| 1783 | |
| 1784 | if len(sys.argv) == 1: |
| 1785 | print("No arguments provided. Load GUI...") |
| 1786 | create_gui() |
| 1787 | else: |
| 1788 | output_dir = os.path.abspath(args.output) |
| 1789 | os.makedirs(output_dir, exist_ok=True) |
| 1790 | |
| 1791 | if args.local: |
| 1792 | copy_local_files(args.local, output_dir) |
| 1793 | |
| 1794 | #print("URL NULL: ", args.url != "", type(args.url)) |
| 1795 | |
| 1796 | if args.url: |
| 1797 | sources = [] |
| 1798 | for u in args.url: |
| 1799 | if re.match(r'\d+\.\d+\.\d+\.\d+', u): # Single IP |
| 1800 | if is_web_server(u): |
| 1801 | sources.append(f"http://{u}/") |
| 1802 | elif re.match(r'^\d+\.\d+\.\d+\.\d+/\d+$', u): # IP range |
| 1803 | sources.extend([f"http://{ip}/" for ip in process_ip_range(u)]) |
| 1804 | else: |
| 1805 | sources.append(u if u.startswith("http") else f"http://{u}/") |
no test coverage detected