apiVersion: batch/v1
kind: Job
metadata:
  name: gausubs-BBS_PROJECT_CODE
  labels:
    app: gausubs-BBS_PROJECT_CODE
spec:
  ttlSecondsAfterFinished: 100
  template:
    metadata:
      labels:
        app: gausubs-BBS_PROJECT_CODE
    spec:
      volumes:
      - name: data-volume
        hostPath: 
          path: /mnt/volume_lon1_01
          type: Directory
      containers:
      - name: gausubs-BBS_PROJECT_CODE
        image: smokingcaterpillar/bbs-osintel-gau-subs
        volumeMounts:
        - name: data-volume
          mountPath: /optdata
        command: 
        - /bin/bash
        - -c
        - |
          echo Gau Subs v1
          echo Code: BBS_PROJECT_CODE
          echo Id: BBS_PROJECT_ID
          echo List: BBS_PROJECT_LIST
          
          ## BBRF SETUP ##        
          echo setting up BBRF...
          cp /optdata/BBS/output/private/bbrs-config.json /root/.bbrf/config.json
          bbrf use BBS_PROJECT_CODE
          ## BBRF SETUP ##
          
          cd /optdata/BBS
          echo removing previous data...
          rm -rf output/project-data/BBS_PROJECT_CODE/data/osintel/gau-subs/data/
          echo reading list items
          counter=0
          #input="output/project-data/BBS_PROJECT_CODE/scope/generated/inscope.wildcard-domains.txt"
          input="output/project-data/BBS_PROJECT_CODE/BBS_PROJECT_LIST"
          while IFS= read -r line
          do
            echo Running Gau on "$line"
            domainname=`echo http://$line | unfurl format %r.%t`
            echo looking up $domainname
            mkdir -p output/project-data/BBS_PROJECT_CODE/data/osintel/gau-subs/data/$HOSTNAME/
            gau -o output/project-data/BBS_PROJECT_CODE/data/osintel/gau-subs/data/$HOSTNAME/$HOSTNAME.$counter.urls.txt -subs $domainname
            

            cat output/project-data/BBS_PROJECT_CODE/data/osintel/gau-subs/data/$HOSTNAME/$HOSTNAME.$counter.urls.txt  | bbrf url add - -t "added_by:gau-subs"
            
            
            
            counter=$((counter+1))
          done < "$input"
          
          
          
      
          echo all done
      restartPolicy: Never

