Class: Pastenum::Gist

Inherits:
Target
  • Object
show all
Defined in:
lib/pastenum/targets/gist.rb

Instance Attribute Summary

Attributes inherited from Target

#dork, #max_pages, #raw, #raw_url, #results, #vendor, #verbose

Instance Method Summary collapse

Methods inherited from Target

#summary, #verify_ssl_mode, #verify_ssl_mode=

Constructor Details

#initialize(dork) ⇒ Gist

Returns a new instance of Gist.



5
6
7
8
9
10
11
# File 'lib/pastenum/targets/gist.rb', line 5

def initialize(dork)
  @dork = URI.escape(dork)
  @vendor = "https://gist.github.com/"
  @raw_url = "https://raw.github.com/gist/"
  
  super
end

Instance Method Details

#searchObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pastenum/targets/gist.rb', line 13

def search
  puts "[*] Searching Gist".green if @verbose
  current_page = 1
  page_numbers.times do
    print ".".green if @verbose
    page = @agent.get("https://gist.github.com/search?page=#{current_page}&q=#{@dork}")
      page.links.each do |link|   
        if @raw
        # Raw links do not use username only the code            
        # "4556950"
         if link.href.match(/[a-zA-Z0-9\-_\.]+\/([0-9]+)/)
             @results <<  link.href.match(/[a-zA-Z0-9\-_\.]+\/([0-9]+)/)[1] 
          end
        else 
        # Example Hits to find stad links need username
        # "/shadowbq/4556950"
        # "/shadowbq/2718948"
          if link.href.match(/([a-zA-Z0-9\-_\.]+\/[0-9]+)/)
             @results << link.href.match(/([a-zA-Z0-9\-_\.]+\/[0-9]+)/)[1]
          end
        end
        
    end
    current_page += 1
  end
  
  puts "\n" if @verbose
  return @results.uniq!  #light years faster than array.include X times along with an extra regex match
end