syspy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/syspy_standalone.rb +44 -0
- data/syspy.rb +1 -45
- metadata +5 -5
- data/bin/syspy +0 -3
@@ -0,0 +1,44 @@
|
|
1
|
+
module Syspy
|
2
|
+
if(ARGV.size != 3)
|
3
|
+
puts "Usage: sudo ruby syspy.rb <interface> <destination_ip> <destination_port>"
|
4
|
+
exit(1)
|
5
|
+
end
|
6
|
+
|
7
|
+
if(`id -u`.strip != "0")
|
8
|
+
puts "Has to be run as root"
|
9
|
+
exit(2)
|
10
|
+
end
|
11
|
+
|
12
|
+
INTERFACE = ARGV[0]
|
13
|
+
DST = ARGV[1]
|
14
|
+
DST_PORT = ARGV[2]
|
15
|
+
|
16
|
+
# INTERFACE = "eth0"
|
17
|
+
# DST = "192.168.1.6"
|
18
|
+
# DST_PORT = "2048"
|
19
|
+
|
20
|
+
stream = TdsPackageStream.new(INTERFACE,DST,DST_PORT)
|
21
|
+
stream.each_package(){|package|
|
22
|
+
if(package.instance_of?(TdsLanguage))
|
23
|
+
statement = package.language_text
|
24
|
+
replaced_statement = "#{statement}"
|
25
|
+
|
26
|
+
index = 0
|
27
|
+
if(package.tds_params)
|
28
|
+
params = package.tds_params.parameters
|
29
|
+
statement.scan(/@sql\d+[^ ]+/){|match|
|
30
|
+
param = params[index]
|
31
|
+
if(param.instance_of?(String))
|
32
|
+
replaced_statement.gsub!(match,"\"#{param}\"")
|
33
|
+
elsif(param.kind_of?(Numeric))
|
34
|
+
replaced_statement.gsub!(match,param.to_s)
|
35
|
+
elsif(param.instance_of?(Time))
|
36
|
+
replaced_statement.gsub!(match,"\"#{param.strftime("%Y%m%d %H:%M:%S")}\"")
|
37
|
+
end
|
38
|
+
index += 1
|
39
|
+
}
|
40
|
+
end
|
41
|
+
Log.info("Replaced parameters: #{index}\n\n#{replaced_statement.gsub("\n","\r\n")}\n------------------------------------------------------")
|
42
|
+
end
|
43
|
+
}
|
44
|
+
end
|
data/syspy.rb
CHANGED
@@ -3,52 +3,8 @@ require "lib/log"
|
|
3
3
|
require "lib/tds_package_stream"
|
4
4
|
require "time"
|
5
5
|
|
6
|
-
|
7
6
|
module Syspy
|
8
|
-
|
9
|
-
if(ARGV.size != 3)
|
10
|
-
puts "Usage: sudo ruby syspy.rb <interface> <destination_ip> <destination_port>"
|
11
|
-
exit(1)
|
12
|
-
end
|
13
|
-
|
14
|
-
if(`id -u`.strip != "0")
|
15
|
-
puts "Has to be run as root"
|
16
|
-
exit(2)
|
17
|
-
end
|
18
|
-
|
19
|
-
INTERFACE = ARGV[0]
|
20
|
-
DST = ARGV[1]
|
21
|
-
DST_PORT = ARGV[2]
|
22
|
-
|
23
|
-
# INTERFACE = "eth0"
|
24
|
-
# DST = "192.168.1.6"
|
25
|
-
# DST_PORT = "2048"
|
26
|
-
|
27
|
-
stream = TdsPackageStream.new(INTERFACE,DST,DST_PORT)
|
28
|
-
stream.each_package(){|package|
|
29
|
-
if(package.instance_of?(TdsLanguage))
|
30
|
-
statement = package.language_text
|
31
|
-
replaced_statement = "#{statement}"
|
32
|
-
|
33
|
-
index = 0
|
34
|
-
if(package.tds_params)
|
35
|
-
params = package.tds_params.parameters
|
36
|
-
statement.scan(/@sql\d+[^ ]+/){|match|
|
37
|
-
param = params[index]
|
38
|
-
if(param.instance_of?(String))
|
39
|
-
replaced_statement.gsub!(match,"\"#{param}\"")
|
40
|
-
elsif(param.kind_of?(Numeric))
|
41
|
-
replaced_statement.gsub!(match,param.to_s)
|
42
|
-
elsif(param.instance_of?(Time))
|
43
|
-
replaced_statement.gsub!(match,"\"#{param.strftime("%Y%m%d %H:%M:%S")}\"")
|
44
|
-
end
|
45
|
-
index += 1
|
46
|
-
}
|
47
|
-
end
|
48
|
-
Log.info("Replaced parameters: #{index}\n\n#{replaced_statement.gsub("\n","\r\n")}\n------------------------------------------------------")
|
49
|
-
end
|
50
|
-
}
|
51
|
-
end
|
7
|
+
|
52
8
|
end
|
53
9
|
|
54
10
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syspy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthias Balmer
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
description:
|
35
35
|
email: matthias.balmer@sysinf.ch
|
36
36
|
executables:
|
37
|
-
-
|
37
|
+
- syspy_standalone.rb
|
38
38
|
extensions: []
|
39
39
|
|
40
40
|
extra_rdoc_files: []
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- lib/tds_packages/tds_language.rb
|
52
52
|
- lib/log.rb
|
53
53
|
- lib/tds_package.rb
|
54
|
-
- bin/
|
54
|
+
- bin/syspy_standalone.rb
|
55
55
|
homepage:
|
56
56
|
licenses: []
|
57
57
|
|
data/bin/syspy
DELETED