|
| 1 | +name: Ominis Search |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + query: |
| 7 | + description: 'Search query/username' |
| 8 | + required: true |
| 9 | + language: |
| 10 | + description: 'Language code (e.g., lang_en)' |
| 11 | + required: false |
| 12 | + default: 'lang_en' |
| 13 | + country: |
| 14 | + description: 'Country code (e.g., US)' |
| 15 | + required: false |
| 16 | + default: 'US' |
| 17 | + start_date: |
| 18 | + description: 'Start date (YYYY-MM-DD)' |
| 19 | + required: false |
| 20 | + end_date: |
| 21 | + description: 'End date (YYYY-MM-DD)' |
| 22 | + required: false |
| 23 | + include_username_search: |
| 24 | + description: 'Perform username search' |
| 25 | + required: true |
| 26 | + type: boolean |
| 27 | + default: true |
| 28 | + include_titles: |
| 29 | + description: 'Include titles in username search results' |
| 30 | + required: false |
| 31 | + type: boolean |
| 32 | + default: true |
| 33 | + include_descriptions: |
| 34 | + description: 'Include descriptions in username search results' |
| 35 | + required: false |
| 36 | + type: boolean |
| 37 | + default: true |
| 38 | + include_html: |
| 39 | + description: 'Include HTML content in username search results' |
| 40 | + required: false |
| 41 | + type: boolean |
| 42 | + default: false |
| 43 | + |
| 44 | +jobs: |
| 45 | + ominis-search: |
| 46 | + runs-on: ubuntu-22.04 |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Set up Python |
| 51 | + uses: actions/setup-python@v5 |
| 52 | + with: |
| 53 | + python-version: '3.9' |
| 54 | + |
| 55 | + - name: Install dependencies |
| 56 | + run: | |
| 57 | + sudo python -m pip install --upgrade pip |
| 58 | + sudo pip install -r requirements.txt |
| 59 | + sudo apt-get update && sudo apt-get install -y tor |
| 60 | +
|
| 61 | + - name: Start Tor service |
| 62 | + run: | |
| 63 | + sudo service tor start |
| 64 | + sudo timeout 30 tail -f /var/log/tor/log || true |
| 65 | +
|
| 66 | + - name: Create Results directory |
| 67 | + run: | |
| 68 | + sudo mkdir -p Results |
| 69 | + sudo chmod 777 Results |
| 70 | +
|
| 71 | + - name: Setup environment |
| 72 | + run: | |
| 73 | + sudo mkdir -p src/logs |
| 74 | + sudo touch src/gfetcherror.log |
| 75 | + sudo touch src/username_search.log |
| 76 | + sudo chmod -R 777 src/logs |
| 77 | + sudo chmod 666 src/gfetcherror.log |
| 78 | + sudo chmod 666 src/username_search.log |
| 79 | +
|
| 80 | + - name: Create proxy configuration |
| 81 | + run: | |
| 82 | + sudo bash -c 'cat > proxy_config.py << EOL |
| 83 | + import aiohttp |
| 84 | + from aiohttp_socks import ProxyConnector |
| 85 | + import asyncio |
| 86 | + import random |
| 87 | + import time |
| 88 | + import subprocess |
| 89 | +
|
| 90 | + last_rotation = 0 |
| 91 | + ROTATION_INTERVAL = 60 # 1 min in sec |
| 92 | +
|
| 93 | + async def get_tor_session(): |
| 94 | + connector = ProxyConnector.from_url("socks5://127.0.0.1:9050") |
| 95 | + return aiohttp.ClientSession(connector=connector) |
| 96 | +
|
| 97 | + async def rotate_tor_identity(): |
| 98 | + global last_rotation |
| 99 | + current_time = time.time() |
| 100 | + |
| 101 | + if current_time - last_rotation >= ROTATION_INTERVAL: |
| 102 | + try: |
| 103 | + subprocess.run(["sudo", "killall", "-HUP", "tor"]) |
| 104 | + await asyncio.sleep(random.uniform(2, 4)) |
| 105 | + last_rotation = current_time |
| 106 | + print("🔄 Rotated Tor identity") |
| 107 | + except Exception as e: |
| 108 | + print(f"Failed to rotate Tor identity: {e}") |
| 109 | + pass |
| 110 | +
|
| 111 | + async def check_and_rotate(): |
| 112 | + while True: |
| 113 | + await rotate_tor_identity() |
| 114 | + await asyncio.sleep(10) |
| 115 | + EOL' |
| 116 | + sudo chmod 666 proxy_config.py |
| 117 | +
|
| 118 | + - name: Configure Tor control |
| 119 | + run: | |
| 120 | + sudo bash -c 'echo "ControlPort 9051" >> /etc/tor/torrc' |
| 121 | + sudo bash -c 'echo "CookieAuthentication 1" >> /etc/tor/torrc' |
| 122 | + sudo service tor restart |
| 123 | + sudo timeout 30 tail -f /var/log/tor/log || true |
| 124 | +
|
| 125 | + - name: Create input simulation script |
| 126 | + run: | |
| 127 | + sudo bash -c 'cat > input_sim.py << EOL |
| 128 | + def mock_input(prompt): |
| 129 | + import os |
| 130 | + if "proxy rotation display" in prompt.lower(): |
| 131 | + return "y" |
| 132 | + if "Include titles" in prompt: |
| 133 | + return "y" if os.environ.get("INCLUDE_TITLES", "false").lower() == "true" else "n" |
| 134 | + if "Include descriptions" in prompt: |
| 135 | + return "y" if os.environ.get("INCLUDE_DESCRIPTIONS", "false").lower() == "true" else "n" |
| 136 | + if "Include HTML content" in prompt: |
| 137 | + return "y" if os.environ.get("INCLUDE_HTML", "false").lower() == "true" else "n" |
| 138 | + if "run a username search" in prompt.lower(): |
| 139 | + return "y" if os.environ.get("DO_USERNAME_SEARCH", "false").lower() == "true" else "n" |
| 140 | + return "" |
| 141 | +
|
| 142 | + import builtins |
| 143 | + builtins.input = mock_input |
| 144 | + EOL' |
| 145 | + sudo chmod 666 input_sim.py |
| 146 | +
|
| 147 | + - name: Run web search |
| 148 | + env: |
| 149 | + PYTHONPATH: ${{ github.workspace }} |
| 150 | + run: | |
| 151 | + sudo python -c " |
| 152 | + import input_sim |
| 153 | + import asyncio |
| 154 | + import proxy_config |
| 155 | + from src.tools_handler import fetch_google_results |
| 156 | +
|
| 157 | + async def main(): |
| 158 | + rotation_task = asyncio.create_task(proxy_config.check_and_rotate()) |
| 159 | + try: |
| 160 | + await fetch_google_results( |
| 161 | + query='${{ github.event.inputs.query }}', |
| 162 | + language='${{ github.event.inputs.language }}', |
| 163 | + country='${{ github.event.inputs.country }}', |
| 164 | + date_range=('${{ github.event.inputs.start_date }}', '${{ github.event.inputs.end_date }}'), |
| 165 | + proxies=['socks5://127.0.0.1:9050'] |
| 166 | + ) |
| 167 | + finally: |
| 168 | + rotation_task.cancel() |
| 169 | +
|
| 170 | + asyncio.run(main()) |
| 171 | + " |
| 172 | +
|
| 173 | + - name: Run username search |
| 174 | + if: ${{ github.event.inputs.include_username_search == 'true' }} |
| 175 | + env: |
| 176 | + INCLUDE_TITLES: ${{ github.event.inputs.include_titles }} |
| 177 | + INCLUDE_DESCRIPTIONS: ${{ github.event.inputs.include_descriptions }} |
| 178 | + INCLUDE_HTML: ${{ github.event.inputs.include_html }} |
| 179 | + PYTHONPATH: ${{ github.workspace }} |
| 180 | + run: | |
| 181 | + sudo python -c " |
| 182 | + import input_sim |
| 183 | + import asyncio |
| 184 | + import proxy_config |
| 185 | + from src.usr import main |
| 186 | +
|
| 187 | + async def run_search(): |
| 188 | + rotation_task = asyncio.create_task(proxy_config.check_and_rotate()) |
| 189 | + try: |
| 190 | + main('${{ github.event.inputs.query }}') |
| 191 | + finally: |
| 192 | + rotation_task.cancel() |
| 193 | +
|
| 194 | + asyncio.run(run_search()) |
| 195 | + " |
| 196 | +
|
| 197 | + - name: Upload results |
| 198 | + uses: actions/upload-artifact@v4 |
| 199 | + with: |
| 200 | + name: ominis-search-results |
| 201 | + path: | |
| 202 | + results/*.txt |
| 203 | + src/*.log |
| 204 | + if-no-files-found: warn |
0 commit comments