Module: PWN::Plugins::Github
- Defined in:
- lib/pwn/plugins/github.rb
Overview
This plugin is used for interacting w/ Github’s REST API using the ‘rest’ browser type of PWN::Plugins::TransparentBrowser.
Constant Summary collapse
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.download_all_gists(opts = {}) ⇒ Object
- Supported Method Parameters
-
response_json = PWN::Plugins::Github.download_all_gists( username: ‘required - username of gists to backup’, target_dir: ‘required - target directory to save respective gists’ ).
-
.help ⇒ Object
Display Usage for this Module.
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
117 118 119 120 121 |
# File 'lib/pwn/plugins/github.rb', line 117 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.download_all_gists(opts = {}) ⇒ Object
- Supported Method Parameters
-
response_json = PWN::Plugins::Github.download_all_gists(
username: 'required - username of gists to backup', target_dir: 'required - target directory to save respective gists'
)
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/pwn/plugins/github.rb', line 75 public_class_method def self.download_all_gists(opts = {}) username = opts[:username].to_s.scrub target_dir = opts[:target_dir].to_s.scrub raise "ERROR: #{target_dir} Does Not Exist." unless Dir.exist?(target_dir) params = {} page = 1 response_json = [{}] while response_json.any? params[:page] = page response_body = github_rest_call( rest_call: "users/#{username}/gists", params: params ).body Dir.chdir(target_dir) response_json = JSON.parse(response_body, symbolize_names: true) response_json.each do |gist_hash| clone_dir = gist_hash[:id] clone_uri = gist_hash[:git_pull_url] next if Dir.exist?(clone_dir) print "Cloning: #{clone_uri}..." system( 'git', 'clone', clone_uri ) puts 'complete.' end page += 1 end response_json rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/pwn/plugins/github.rb', line 125 public_class_method def self.help puts "USAGE: response_json = #{self}.download_all_gists( username: 'required - username of gists to download', target_dir: 'required - target directory to save respective gists' ) #{self}.authors " end |