apiVersion: batch/v1
kind: Job
metadata:
  name: naabu-BBS_PROJECT_CODE
  labels:
    app: naabu-BBS_PROJECT_CODE
spec:
  ttlSecondsAfterFinished: 100
  template:
    metadata:
      labels:
        app: naabu-BBS_PROJECT_CODE
    spec:
      volumes:
      - name: data-volume
        hostPath: 
          path: /mnt/volume_lon1_01
          type: Directory
      containers:
      - name: naabu-BBS_PROJECT_CODE
        image: smokingcaterpillar/bbs-osintel-github-subs
        volumeMounts:
        - name: data-volume
          mountPath: /optdata
        command: 
        - /bin/bash
        - -c
        - |
          echo naabu 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 ##
          
          apt update
          apt-get install libpcap-dev nmap -y

          
          GO111MODULE=on go get -v github.com/projectdiscovery/naabu/v2/cmd/naabu
          
          
          mkdir -p /optdata/BBS/output/project-data/BBS_PROJECT_CODE/data/scanner/naabu/data/$HOSTNAME/
          cd /optdata/BBS/output/project-data/BBS_PROJECT_CODE/data/scanner/naabu/
          
          naabu -exclude-cdn -no-color -p - -o naabu.log.txt -nmap-cli 'nmap -sV -oA naabu-output' -iL "/optdata/BBS/output/project-data/BBS_PROJECT_CODE/BBS_PROJECT_LIST" 
          
          NMAP_FILE=naabu-output.gnmap
          egrep -v "^#|Status: Up" $NMAP_FILE | cut -d' ' -f2,4- | sed  -e 's/Ignored.*//p'  | awk '{for(i=2; i<=NF; i++) { a=a" "$i; }; split(a,s,","); for(e in s) { split(s[e],v,"/"); printf "%s:%s:%s\n" , $1, v[1], v[5]}; a="" }' > tmp1.txt
          cat tmp1.txt | tr -d '[:blank:]' > bbrftext.txt 
          
          #cat bbrftext.txt | bbrf service add - -p "BBS_PROJECT_CODE" -s naabu


          
          cat bbrfdata.txt
          #bbrf service add - -t hostname:$i 

          
          
                    
          echo all done
      restartPolicy: Never

