Module: PWN::WWW::GitHub

Defined in:
lib/pwn/www/github.rb

Overview

This plugin supports github.com actions.

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. support@0dayinc.com



138
139
140
141
142
# File 'lib/pwn/www/github.rb', line 138

public_class_method def self.authors
  "AUTHOR(S):
    0day Inc. <support@0dayinc.com>
  "
end

.close(opts = {}) ⇒ Object

Supported Method Parameters

browser_obj = PWN::WWW::GitHub.close( browser_obj: 'required - browser_obj returned from #open method' )



127
128
129
130
131
132
133
134
# File 'lib/pwn/www/github.rb', line 127

public_class_method def self.close(opts = {})
  browser_obj = opts[:browser_obj]
  PWN::Plugins::TransparentBrowser.close(
    browser_obj: browser_obj
  )
rescue StandardError => e
  raise e
end

.helpObject

Display Usage for this Module



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/pwn/www/github.rb', line 146

public_class_method def self.help
  puts "USAGE:
    browser_obj = #{self}.open(
      browser_type: 'optional - :firefox|:chrome|:ie|:headless (Defaults to :firefox)',
      proxy: 'optional - scheme://proxy_host:port || tor'
    )

    browser_obj = #{self}.login(
      browser_obj: 'required - browser_obj returned from #open method',
      username: 'required - username',
      password: 'optional - passwd (will prompt if blank),
      mfa: 'optional - MFA / TOTP token string, or true to prompt (defaults to false)',
      mfa_token: 'optional - MFA / TOTP token used to reach a post-authenticated state'
    )

    browser_obj = #{self}.logout(
      browser_obj: 'required - browser_obj returned from #open method'
    )

    #{self}.close(
      browser_obj: 'required - browser_obj returned from #open method'
    )

    #{self}.authors
  "
end

.login(opts = {}) ⇒ Object

Supported Method Parameters

browser_obj = PWN::WWW::GitHub.login( browser_obj: 'required - browser_obj returned from #open method', username: 'required - username', password: 'optional - passwd (will prompt if blank)', mfa: 'optional - MFA / TOTP token string, or true to prompt (defaults to false)', mfa_token: 'optional - MFA / TOTP token used to reach a post-authenticated state' )



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/pwn/www/github.rb', line 35

public_class_method def self.(opts = {})
  browser_obj = opts[:browser_obj]
  username = opts[:username].to_s.scrub.strip.chomp
  password = opts[:password]

  browser = browser_obj[:browser]

  if password.nil?
    password = PWN::Plugins::AuthenticationHelper.mask_password
  else
    password = opts[:password].to_s.scrub.strip.chomp
  end
  mfa = opts[:mfa]
  mfa_token = opts[:mfa_token].to_s.scrub.strip.chomp
  mfa_token = mfa.to_s.scrub.strip.chomp if mfa_token.empty? && mfa.is_a?(String)

  browser.goto('https://github.com/login')

  browser.text_field(name: 'login').wait_until(&:present?).set(username)
  browser.text_field(name: 'password').wait_until(&:present?).set(password)
  browser.input(name: 'commit').click!

  if mfa || !mfa_token.empty?
    until browser.url == 'https://github.com/' ||
          browser.url.include?('https://github.com/dashboard') ||
          (
            browser.url.start_with?('https://github.com/') &&
            !browser.url.include?('/login') &&
            !browser.url.include?('/session')
          )

      token = if mfa_token.empty?
                PWN::Plugins::AuthenticationHelper.mfa(prompt: 'enter mfa token')
              else
                consumed = mfa_token
                mfa_token = ''
                consumed
              end

      if browser.text_field(name: 'app_otp').exist?
        browser.text_field(name: 'app_otp').wait_until(&:present?).set(token)
      elsif browser.text_field(id: 'app_totp').exist?
        browser.text_field(id: 'app_totp').wait_until(&:present?).set(token)
      elsif browser.text_field(name: 'otp').exist?
        browser.text_field(name: 'otp').wait_until(&:present?).set(token)
      else
        browser.text_field(name: 'sms_otp').wait_until(&:present?).set(token)
      end

      if browser.input(name: 'commit').exist?
        browser.input(name: 'commit').click!
      elsif browser.button(type: 'submit').exist?
        browser.button(type: 'submit').click!
      end
      sleep 3
    end
    print "\n"
  end

  browser_obj
rescue StandardError => e
  raise e
end

.logout(opts = {}) ⇒ Object

Supported Method Parameters

browser_obj = PWN::WWW::GitHub.logout( browser_obj: 'required - browser_obj returned from #open method' )



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/pwn/www/github.rb', line 104

public_class_method def self.logout(opts = {})
  browser_obj = opts[:browser_obj]

  browser = browser_obj[:browser]
  browser.goto('https://github.com/logout')
  if browser.input(name: 'commit').exist?
    browser.input(name: 'commit').wait_until(&:present?).click!
  elsif browser.button(name: 'commit').exist?
    browser.button(name: 'commit').wait_until(&:present?).click!
  else
    browser.button(text: 'Sign out').wait_until(&:present?).click!
  end

  browser_obj
rescue StandardError => e
  raise e
end

.open(opts = {}) ⇒ Object

Supported Method Parameters

browser_obj = PWN::WWW::GitHub.open( browser_type: 'optional - :firefox|:chrome|:ie|:headless (Defaults to :firefox)', proxy: 'optional - scheme://proxy_host:port || tor' )



15
16
17
18
19
20
21
22
23
24
# File 'lib/pwn/www/github.rb', line 15

public_class_method def self.open(opts = {})
  browser_obj = PWN::Plugins::TransparentBrowser.open(opts)

  browser = browser_obj[:browser]
  browser.goto('https://github.com')

  browser_obj
rescue StandardError => e
  raise e
end