rubypwn 0.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/basic.rb +29 -0
  3. data/lib/rubypwn.rb +71 -0
  4. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3a4860a1c451dbeacfdfe8442d7f8886d07609b8
4
+ data.tar.gz: 40df592c1734fa3e1a69be9cb58fd968cd906ac1
5
+ SHA512:
6
+ metadata.gz: 3c5043d1b33b4ac58b9d2bbe3f561361ee66a549e3b1eca8907e25384ab2667c8278e983f52afab110456268759f23c3b70e9139ea9bcb40090208e83e90964e
7
+ data.tar.gz: 7a8a3e144f100d0130fa33a6f2cab22b99cd0c3ae002f57e34131204f679c6a1eb50e6758c3ec2e21d0c79a988bbe23df036f4809e514bce28fafce4b709c39a
data/lib/basic.rb ADDED
@@ -0,0 +1,29 @@
1
+ def i64(int)
2
+ [int].pack("Q<")
3
+ end
4
+
5
+ def i32(int)
6
+ [int].pack("L<")
7
+ end
8
+
9
+ def s32(str)
10
+ str = str.ljust(4, "\x00")
11
+ str.unpack("L<")[0]
12
+ end
13
+
14
+ def s64(str)
15
+ str = str.ljust(8, "\x00")
16
+ str.unpack("Q<")[0]
17
+ end
18
+
19
+ def i16(int)
20
+ [int].pack("S<")
21
+ end
22
+
23
+ def c(int)
24
+ [int].pack("C")
25
+ end
26
+
27
+ def hex(str)
28
+ str.unpack("H*")[0]
29
+ end
data/lib/rubypwn.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'open3'
2
+ require_relative 'basic'
3
+
4
+ class Shell
5
+ public
6
+ def initialize(cmd)
7
+ handle_exception
8
+ @@i, @@o, s = Open3.popen2(cmd)
9
+ end
10
+
11
+ def read(size)
12
+ data = @@o.read size
13
+ write_flush $stdout, data
14
+ data
15
+ end
16
+
17
+ def readpartial(size)
18
+ data = @@o.readpartial size
19
+ write_flush $stdout, data
20
+ data
21
+ end
22
+
23
+ def write(data)
24
+ write_flush $stdout, data
25
+ write_flush @@i, data
26
+ end
27
+
28
+ def puts(data)
29
+ write "#{data}\n"
30
+ end
31
+
32
+ def gets
33
+ read_until "\n"
34
+ end
35
+
36
+ def read_until(str)
37
+ result = ""
38
+ loop do
39
+ result << @@o.read(1)
40
+ if result.end_with? str
41
+ write_flush $stdout, result
42
+ return result
43
+ end
44
+ end
45
+ end
46
+
47
+ def interactive
48
+ loop do
49
+ r = IO.select [@@o, $stdin]
50
+ if r[0].include? @@o
51
+ read 1
52
+ elsif r[0].include? $stdin
53
+ @@i.write $stdin.read(1)
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+ def write_flush(fd, data)
60
+ fd.write data
61
+ fd.flush
62
+ end
63
+
64
+ def handle_exception
65
+ trap "SIGINT" do
66
+ $stdout.puts
67
+ $stdout.puts "interrupted"
68
+ exit -1
69
+ end
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubypwn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - atdog
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: pwn tools
14
+ email: atdog.tw@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/basic.rb
20
+ - lib/rubypwn.rb
21
+ homepage: http://rubygems.org/gems/rubypwn
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.8
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: pwn tools - ruby version
45
+ test_files: []