pwnix-api-client 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.bundle/config ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ BUNDLE_PATH: .bundle
3
+ BUNDLE_DISABLE_SHARED_GEMS: '1'
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ ._.DS_Store
3
+
4
+ # Dependencies
5
+ .bundle/ruby
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem 'json'
4
+ gem 'httparty'
5
+
6
+ group :test do
7
+ gem 'pry'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,24 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coderay (1.0.7)
5
+ httparty (0.9.0)
6
+ multi_json (~> 1.0)
7
+ multi_xml
8
+ json (1.7.5)
9
+ method_source (0.8)
10
+ multi_json (1.3.6)
11
+ multi_xml (0.5.1)
12
+ pry (0.9.10)
13
+ coderay (~> 1.0.5)
14
+ method_source (~> 0.8)
15
+ slop (~> 3.3.1)
16
+ slop (3.3.3)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ httparty
23
+ json
24
+ pry
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ pwnix-api-client
2
+ ================
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ task :build do
4
+ Rake::Task['clean'].execute
5
+ puts "[*] Building pwnix-api-client.gemspec"
6
+ system "gem build pwnix-api-client.gemspec &> /dev/null"
7
+ end
8
+
9
+ task :release => :build do
10
+ puts "[*] Pushing pwnix-api-client to rubygems.org"
11
+ system "gem push pwnix-api-client-*.gem &> /dev/null"
12
+ Rake::Task['clean'].execute
13
+ end
14
+
15
+ task :clean do
16
+ system "rm *.gem &> /dev/null"
17
+ end
@@ -0,0 +1,72 @@
1
+ # Command Line Hint Method
2
+ # So you can see what the heck you are supposed to include as config
3
+ def hint
4
+ puts "Example Enable Call for #{@shell_name}:"
5
+ puts " client.shells['#{@shell_name}'].enable("
6
+ puts " #{example_value.inspect}"
7
+ puts " )"
8
+ end
9
+
10
+ def example_value(shell_name)
11
+
12
+ # These are just examples of appropriate configs for each shell type
13
+ case shell_name
14
+ when "dns"
15
+ {
16
+ :active => 'true',
17
+ :ip => '192.168.1.1',
18
+ :cron => 'five_minutes'
19
+ }
20
+ when "gsm"
21
+ {
22
+ :active => 'true',
23
+ :ip => '192.168.1.1',
24
+ :adapter => 'tmobile',
25
+ :port => '123',
26
+ :cron => 'five_minutes',
27
+ }
28
+ when "http"
29
+ {
30
+ :active => 'true',
31
+ :ip => '50.1.1.1',
32
+ :proxy => 'true',
33
+ :proxy_ip => '192.168.1.1',
34
+ :proxy_port => '123',
35
+ :proxy_auth_user => 'user',
36
+ :proxy_auth_password => 'P@55w3rd',
37
+ :cron => 'five_minutes',
38
+ }
39
+ when "icmp"
40
+ {
41
+ :active => 'true',
42
+ :ip => '192.168.1.1',
43
+ :cron => 'five_minutes',
44
+ }
45
+ when "ssl"
46
+ {
47
+ :active => 'true',
48
+ :ip => '192.168.1.1',
49
+ :cron => 'five_minutes',
50
+ }
51
+ when "tcp"
52
+ {
53
+ :active => 'true',
54
+ :ip => '192.168.1.1',
55
+ :port => '123',
56
+ :cron => 'five_minutes',
57
+ }
58
+ when "egress_buster"
59
+ extra_fields = %w{ enable21 enable22 enable23 enable25 enable110 enable123 enable161 enable500 enable1723 enable4500 }
60
+ output = {
61
+ :active => 'true',
62
+ :ip => '192.168.1.1',
63
+ :cron => 'five_minutes',
64
+ }
65
+ extra_fields.inject(output) do |out, field|
66
+ out[field] = 'true'
67
+ out
68
+ end
69
+ else
70
+ "Invalid Shell Name"
71
+ end
72
+ end
@@ -0,0 +1,2 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__)))
2
+ require 'pwnix-api-client/api_client'
@@ -0,0 +1,80 @@
1
+ require 'httparty'
2
+
3
+ module Pwnix
4
+ module Api
5
+ module Client
6
+ BASE_URI = "https://localhost:7967/v1"
7
+ #BASE_URI = "http://localhost:9292/v1"
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'system'
13
+ require_relative 'shell'
14
+ require_relative 'mode'
15
+ require_relative 'service'
16
+
17
+ module Pwnix
18
+ module Api
19
+ module Client
20
+
21
+
22
+ =begin
23
+ module AuthdClient
24
+ include Httparty
25
+
26
+ def initialize(config={})
27
+ username = config[:username]
28
+ password = config[:password]
29
+ server = config[:server] || "localhost"
30
+
31
+ # Configure with Basic auth for the API
32
+ if username && password
33
+ self.class.basic_auth username,password
34
+ end
35
+ end
36
+
37
+ end
38
+ =end
39
+
40
+ class ApiClient
41
+
42
+ attr_accessor :base_uri
43
+ attr_accessor :system
44
+ attr_accessor :shells
45
+ attr_accessor :services
46
+ attr_accessor :modes
47
+
48
+ def initialize(config={})
49
+
50
+ @shells = {
51
+ "dns" => Shell.new("dns"),
52
+ "gsm" => Shell.new("gsm"),
53
+ "http" => Shell.new("http"),
54
+ "icmp" => Shell.new("icmp"),
55
+ "ssl" => Shell.new("ssl"),
56
+ "tcp" => Shell.new("tcp"),
57
+ "egress_buster" => Shell.new("egress_buster")
58
+ }
59
+
60
+ @modes = {
61
+ "normal_mode" => Mode.new("normal_mode"),
62
+ }
63
+
64
+ @system = System.new
65
+
66
+ @services = {
67
+ "evil_ap" => Service.new("evil_ap"),
68
+ "msfrpcd" => Service.new("msfrpcd"),
69
+ "nac_bypass" => Service.new("nac_bypass"),
70
+ "passive_recon" => Service.new("passive_recon"),
71
+ "sshd" => Service.new("sshd"),
72
+ "stealth" => Service.new("stealth"),
73
+ "text_to_bash" => Service.new("text_to_bash")
74
+ }
75
+
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,41 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Mode
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def initialize(mode_name)
11
+ @mode_name = mode_name
12
+ end
13
+
14
+ def start
15
+ self.class.post("/mode/#{@mode_name}/start", :body => {}).parsed_response['result']
16
+ end
17
+
18
+ def stop
19
+ self.class.post("/mode/#{@mode_name}/stop", :body => {}).parsed_response['result']
20
+ end
21
+
22
+ def status
23
+ self.class.post("/mode/#{@mode_name}/status", :body => {}).parsed_response['result']
24
+ end
25
+
26
+ def status_string
27
+ self.class.post("/mode/#{@mode_name}/status_string", :body => {}).parsed_response['result']
28
+ end
29
+
30
+ def running?
31
+ self.class.post("/mode/#{@mode_name}/running", :body => {}).parsed_response['result']
32
+ end
33
+
34
+ def available?
35
+ self.class.post("/mode/#{@mode_name}/available", :body => {}).parsed_response['result']
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,49 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Service
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def initialize(service_name)
11
+ @service_name = service_name
12
+ end
13
+
14
+ def status
15
+ self.class.post("/services/#{@service_name}/status", :body => {}).parsed_response['result']
16
+ end
17
+
18
+ def status_string
19
+ self.class.post("/services/#{@service_name}/status_string", :body => {}).parsed_response['result']
20
+ end
21
+
22
+ def running?
23
+ self.class.post("/services/#{@service_name}/running", :body => {}).parsed_response['result']
24
+ end
25
+
26
+ def available?
27
+ self.class.post("/services/#{@service_name}/available", :body => {}).parsed_response['result']
28
+ end
29
+
30
+ def start
31
+ self.class.post("/services/#{@service_name}/start", :body => {}).parsed_response['result']
32
+ end
33
+
34
+ def stop
35
+ self.class.post("/services/#{@service_name}/stop", :body => {}).parsed_response['result']
36
+ end
37
+
38
+ def enable
39
+ self.class.post("/services/#{@service_name}/enable", :body => {}).parsed_response['result']
40
+ end
41
+
42
+ def disable
43
+ self.class.post("/services/#{@service_name}/disable", :body => {}).parsed_response['result']
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,37 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Shell
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def initialize(shell_name)
11
+ @shell_name = shell_name
12
+ end
13
+
14
+ def status
15
+ self.class.post("/shells/#{@shell_name}/status", :body => {}).parsed_response['result']
16
+ end
17
+
18
+ def running?
19
+ self.class.post("/shells/#{@shell_name}/running", :body => {}).parsed_response['result']
20
+ end
21
+
22
+ def configure(config={}) # Configuration options
23
+ self.class.post("/shells/#{@shell_name}/configure", :body => config).parsed_response['result']
24
+ end
25
+
26
+ def enable
27
+ self.class.post("/shells/#{@shell_name}/enable", :body => {}).parsed_response['result']
28
+ end
29
+
30
+ def disable
31
+ self.class.post("/shells/#{@shell_name}/disable", :body => {}).parsed_response['result']
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'system/hardware'
2
+ require_relative 'system/logs'
3
+ require_relative 'system/network'
4
+ require_relative 'system/os'
5
+ require_relative 'system/server'
6
+ require_relative 'system/sms'
7
+ require_relative 'system/ssh'
8
+
9
+ module Pwnix
10
+ module Api
11
+ module Client
12
+ class System
13
+ include HTTParty
14
+ base_uri Pwnix::Api::Client::BASE_URI
15
+ debug_output
16
+ format :json
17
+
18
+ attr_accessor :logs, :network, :hardware
19
+ attr_accessor :os, :server, :sms, :ssh
20
+
21
+ def initialize
22
+ @hardware = Hardware.new
23
+ @logs = Logs.new
24
+ @network = Network.new
25
+ @os = Os.new
26
+ @server = Server.new
27
+ @sms = Sms.new
28
+ @ssh = Ssh.new
29
+ end
30
+
31
+ def status
32
+ self.class.post("/system/status", :body => {}).parsed_response['result']
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Hardware
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def status
11
+ self.class.post("/system/hardware/status", :body => {}).parsed_response['result']
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Logs
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def list
11
+ self.class.post("/system/logs/list", :body => {}).parsed_response['result']
12
+ end
13
+
14
+ def tail(name)
15
+ self.class.post("/system/logs/tail", :body => { :log_name => name }).parsed_response['result']
16
+ end
17
+
18
+ def head(name)
19
+ self.class.post("/system/logs/head", :body => { :log_name => name }).parsed_response['result']
20
+ end
21
+
22
+ def contents(name)
23
+ self.class.post("/system/logs/contents", :body => { :log_name => name }).parsed_response['result']
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Network
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def status
11
+ self.class.post("/system/network/status", :body => {}).parsed_response['result']
12
+ end
13
+
14
+ def change_mac(mac=nil)
15
+ if mac
16
+ self.class.post("/system/network/status", :body => { :mac => mac } ).parsed_response['result']
17
+ else
18
+ self.class.post("/system/network/status", :body => {}).parsed_response['result']
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Os
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def status
11
+ self.class.post("/system/os/status", :body => {}).parsed_response['result']
12
+ end
13
+
14
+ def filesystem
15
+ self.class.post("/system/os/filesystem", :body => {}).parsed_response['result']
16
+ end
17
+
18
+ def netstat
19
+ self.class.post("/system/os/netstat", :body => {}).parsed_response['result']
20
+ end
21
+
22
+ def cleanup
23
+ self.class.post("/system/os/cleanup", :body => {}).parsed_response['result']
24
+ end
25
+
26
+ def restart
27
+ self.class.post("/system/os/restart", :body => {}).parsed_response['result']
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,37 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Server
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def status
11
+ self.class.post("/system/server/status", :body => {}).parsed_response['result']
12
+ end
13
+
14
+ def version
15
+ self.class.post("/system/server/version", :body => {}).parsed_response['result']
16
+ end
17
+
18
+ def release
19
+ self.class.post("/system/server/release", :body => {}).parsed_response['result']
20
+ end
21
+
22
+ def update
23
+ self.class.post("/system/server/update", :options => {:timeout => 600}, :body => {}).parsed_response['result']
24
+ end
25
+
26
+ def clear
27
+ self.class.post("/system/server/clear", :body => {}).parsed_response['result']
28
+ end
29
+
30
+ def restart
31
+ self.class.post("/system/server/restart", :body => {}).parsed_response['result']
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,48 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Sms
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def status
11
+ self.class.post("/system/sms/status", :body => {}).parsed_response['result']
12
+ end
13
+
14
+ def set(options={})
15
+ self.class.post(
16
+ "/system/sms/set",
17
+ :body => {
18
+ :configuration => options
19
+ }
20
+ ).parsed_response['result']
21
+ end
22
+
23
+ def test(options={})
24
+ self.class.post(
25
+ "/system/sms/test",
26
+ :body => {
27
+ :configuration => options
28
+ }
29
+ ).parsed_response['result']
30
+ end
31
+
32
+ def hint
33
+ puts "Options Hash for set() example:"
34
+ o = {}
35
+ fields.each do |f|
36
+ o[f] = "#{f}_value"
37
+ end
38
+ puts "\t#{o.inspect}"
39
+ end
40
+
41
+ def fields
42
+ %w{ sms_sender sms_recipient msg_subject msg_body smtp_server smtp_tls smtp_auth_user smtp_auth_password}
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,21 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ class Ssh
5
+ include HTTParty
6
+ base_uri Pwnix::Api::Client::BASE_URI
7
+ debug_output
8
+ format :json
9
+
10
+ def public_key
11
+ self.class.post("/system/ssh/public_key", :body => {}).parsed_response['result']
12
+ end
13
+
14
+ def reset
15
+ self.class.post("/system/ssh/reset", :body => {}).parsed_response['result']
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module Pwnix
2
+ module Api
3
+ module Client
4
+ VERSION = "0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.dirname(File.expand_path(__FILE__))
3
+ require 'lib/pwnix-api-client/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "pwnix-api-client"
7
+ s.version = Pwnix::Api::Client::VERSION
8
+ s.authors = ["Jonathan Cran"]
9
+ s.email = ["jcran@pwnieexpress.com"]
10
+ s.homepage = "http://www.github.com/pwnieexpress/pwnix-api-client"
11
+ s.summary = %q{Pwnix API Client}
12
+ s.description = %q{ Remotely manage a Pwnix device. }
13
+
14
+ #s.rubyforge_project = "PwnixApiClient"
15
+ s.add_runtime_dependency "httparty"
16
+ s.add_runtime_dependency "json"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ end
data/util/console.rb ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pry'
3
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/pwnix-api-client"
4
+
5
+ client = Pwnix::Api::Client::ApiClient.new
6
+ puts "[+] The \"client\" variable holds an instance of the API client."
7
+
8
+ Pry.start(self, :prompt => [proc{"client> "}])
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pwnix-api-client
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jonathan Cran
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: &17373900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *17373900
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &17373480 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *17373480
36
+ description: ! ' Remotely manage a Pwnix device. '
37
+ email:
38
+ - jcran@pwnieexpress.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .bundle/config
44
+ - .gitignore
45
+ - Gemfile
46
+ - Gemfile.lock
47
+ - README.md
48
+ - Rakefile
49
+ - examples/configure_shells.rb
50
+ - lib/pwnix-api-client.rb
51
+ - lib/pwnix-api-client/api_client.rb
52
+ - lib/pwnix-api-client/mode.rb
53
+ - lib/pwnix-api-client/service.rb
54
+ - lib/pwnix-api-client/shell.rb
55
+ - lib/pwnix-api-client/spec/pwnix-api-client-spec.rb
56
+ - lib/pwnix-api-client/system.rb
57
+ - lib/pwnix-api-client/system/hardware.rb
58
+ - lib/pwnix-api-client/system/logs.rb
59
+ - lib/pwnix-api-client/system/network.rb
60
+ - lib/pwnix-api-client/system/os.rb
61
+ - lib/pwnix-api-client/system/server.rb
62
+ - lib/pwnix-api-client/system/sms.rb
63
+ - lib/pwnix-api-client/system/ssh.rb
64
+ - lib/pwnix-api-client/version.rb
65
+ - pwnix-api-client.gemspec
66
+ - util/console.rb
67
+ homepage: http://www.github.com/pwnieexpress/pwnix-api-client
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.11
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Pwnix API Client
91
+ test_files: []