ronin-code-asm 1.0.0.beta1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -2
- data/.ruby-version +1 -1
- data/.yardopts +1 -1
- data/ChangeLog.md +7 -2
- data/Gemfile +2 -2
- data/README.md +66 -5
- data/gemspec.yml +3 -3
- data/lib/ronin/code/asm/archs/amd64.rb +3 -3
- data/lib/ronin/code/asm/archs/x86.rb +6 -6
- data/lib/ronin/code/asm/archs.rb +3 -3
- data/lib/ronin/code/asm/config.rb +1 -1
- data/lib/ronin/code/asm/immediate_operand.rb +1 -1
- data/lib/ronin/code/asm/instruction.rb +2 -2
- data/lib/ronin/code/asm/memory_operand.rb +2 -2
- data/lib/ronin/code/asm/os/freebsd.rb +2 -2
- data/lib/ronin/code/asm/os/linux.rb +2 -2
- data/lib/ronin/code/asm/os/os.rb +2 -2
- data/lib/ronin/code/asm/os.rb +4 -4
- data/lib/ronin/code/asm/program.rb +13 -13
- data/lib/ronin/code/asm/register.rb +3 -3
- data/lib/ronin/code/asm/shellcode.rb +1 -1
- data/lib/ronin/code/asm/syntax/att.rb +1 -1
- data/lib/ronin/code/asm/syntax/common.rb +1 -1
- data/lib/ronin/code/asm/syntax/intel.rb +1 -1
- data/lib/ronin/code/asm/syntax.rb +1 -1
- data/lib/ronin/code/asm/version.rb +2 -2
- data/lib/ronin/code/asm.rb +4 -4
- data/ronin-code-asm.gemspec +2 -1
- metadata +7 -32
- data/spec/asm_spec.rb +0 -14
- data/spec/config_spec.rb +0 -10
- data/spec/immediate_operand_spec.rb +0 -79
- data/spec/instruction_spec.rb +0 -62
- data/spec/memory_operand_spec.rb +0 -80
- data/spec/os_spec.rb +0 -68
- data/spec/program_spec.rb +0 -439
- data/spec/register_spec.rb +0 -112
- data/spec/shellcode_spec.rb +0 -58
- data/spec/spec_helper.rb +0 -7
- data/spec/syntax/att_spec.rb +0 -181
- data/spec/syntax/common_spec.rb +0 -42
- data/spec/syntax/intel_spec.rb +0 -174
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ronin-code-asm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-yasm
|
@@ -86,27 +86,14 @@ files:
|
|
86
86
|
- lib/ronin/code/asm/syntax/intel.rb
|
87
87
|
- lib/ronin/code/asm/version.rb
|
88
88
|
- ronin-code-asm.gemspec
|
89
|
-
- spec/asm_spec.rb
|
90
|
-
- spec/config_spec.rb
|
91
|
-
- spec/immediate_operand_spec.rb
|
92
|
-
- spec/instruction_spec.rb
|
93
|
-
- spec/memory_operand_spec.rb
|
94
|
-
- spec/os_spec.rb
|
95
|
-
- spec/program_spec.rb
|
96
|
-
- spec/register_spec.rb
|
97
|
-
- spec/shellcode_spec.rb
|
98
|
-
- spec/spec_helper.rb
|
99
|
-
- spec/syntax/att_spec.rb
|
100
|
-
- spec/syntax/common_spec.rb
|
101
|
-
- spec/syntax/intel_spec.rb
|
102
89
|
homepage: https://github.com/ronin-rb/ronin-code-asm#readme
|
103
90
|
licenses:
|
104
|
-
- LGPL-3.0
|
91
|
+
- LGPL-3.0-or-later
|
105
92
|
metadata:
|
106
|
-
documentation_uri: https://ronin-rb.dev/docs/ronin-code-asm
|
93
|
+
documentation_uri: https://ronin-rb.dev/docs/ronin-code-asm
|
107
94
|
source_code_uri: https://github.com/ronin-rb/ronin-code-asm
|
108
95
|
bug_tracker_uri: https://github.com/ronin-rb/ronin-code-asm/issues
|
109
|
-
changelog_uri: https://github.com/ronin-rb/ronin-code-asm/blob/
|
96
|
+
changelog_uri: https://github.com/ronin-rb/ronin-code-asm/blob/main/ChangeLog.md
|
110
97
|
rubygems_mfa_required: 'true'
|
111
98
|
post_install_message:
|
112
99
|
rdoc_options: []
|
@@ -124,20 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
111
|
version: '0'
|
125
112
|
requirements:
|
126
113
|
- yasm >= 0.6.0
|
127
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.5.22
|
128
115
|
signing_key:
|
129
116
|
specification_version: 4
|
130
117
|
summary: A Ruby DSL for crafting Assembly programs and Shellcode.
|
131
|
-
test_files:
|
132
|
-
- spec/asm_spec.rb
|
133
|
-
- spec/config_spec.rb
|
134
|
-
- spec/immediate_operand_spec.rb
|
135
|
-
- spec/instruction_spec.rb
|
136
|
-
- spec/memory_operand_spec.rb
|
137
|
-
- spec/os_spec.rb
|
138
|
-
- spec/program_spec.rb
|
139
|
-
- spec/register_spec.rb
|
140
|
-
- spec/shellcode_spec.rb
|
141
|
-
- spec/syntax/att_spec.rb
|
142
|
-
- spec/syntax/common_spec.rb
|
143
|
-
- spec/syntax/intel_spec.rb
|
118
|
+
test_files: []
|
data/spec/asm_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/code/asm'
|
3
|
-
|
4
|
-
describe Ronin::Code::ASM do
|
5
|
-
it "must have a version" do
|
6
|
-
expect(subject.const_defined?('VERSION')).to eq(true)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".new" do
|
10
|
-
it "must return a new Ronin::Code::ASM::Program" do
|
11
|
-
expect(subject.new(arch: :x86)).to be_kind_of(Ronin::Code::ASM::Program)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/config_spec.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'ronin/code/asm/immediate_operand'
|
4
|
-
|
5
|
-
describe Ronin::Code::ASM::ImmediateOperand do
|
6
|
-
let(:value) { 0xff }
|
7
|
-
|
8
|
-
describe "#initialize" do
|
9
|
-
context "with a width" do
|
10
|
-
let(:width) { 2 }
|
11
|
-
|
12
|
-
subject { described_class.new(value,width) }
|
13
|
-
|
14
|
-
it "must set the width" do
|
15
|
-
expect(subject.width).to eq(width)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#width" do
|
21
|
-
describe "default width for" do
|
22
|
-
context "0x100000000 .. 0xffffffffffffffff" do
|
23
|
-
subject { described_class.new(0xffffffffffffffff).width }
|
24
|
-
|
25
|
-
it { expect(subject).to be == 8 }
|
26
|
-
end
|
27
|
-
|
28
|
-
context "-0x800000000 .. -0x7fffffffffffffff" do
|
29
|
-
subject { described_class.new(-0x7fffffffffffffff).width }
|
30
|
-
|
31
|
-
it { expect(subject).to be == 8 }
|
32
|
-
end
|
33
|
-
|
34
|
-
context "0x10000 .. 0xffffffff" do
|
35
|
-
subject { described_class.new(0xffffffff).width }
|
36
|
-
|
37
|
-
it { expect(subject).to be == 4 }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "-0x80000 .. -0x7fffffff" do
|
41
|
-
subject { described_class.new(-0x7fffffff).width }
|
42
|
-
|
43
|
-
it { expect(subject).to be == 4 }
|
44
|
-
end
|
45
|
-
|
46
|
-
context "0x100 .. 0xffff" do
|
47
|
-
subject { described_class.new(0xffff).width }
|
48
|
-
|
49
|
-
it { expect(subject).to be == 2 }
|
50
|
-
end
|
51
|
-
|
52
|
-
context "-0x80 .. -0x7fff" do
|
53
|
-
subject { described_class.new(-0x7fff).width }
|
54
|
-
|
55
|
-
it { expect(subject).to be == 2 }
|
56
|
-
end
|
57
|
-
|
58
|
-
context "0x0 .. 0xff" do
|
59
|
-
subject { described_class.new(0xff).width }
|
60
|
-
|
61
|
-
it { expect(subject).to be == 1 }
|
62
|
-
end
|
63
|
-
|
64
|
-
context "0x0 .. -0x7f" do
|
65
|
-
subject { described_class.new(-0x7f).width }
|
66
|
-
|
67
|
-
it { expect(subject).to be == 1 }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#to_i" do
|
73
|
-
subject { described_class.new(value) }
|
74
|
-
|
75
|
-
it "must return the value" do
|
76
|
-
expect(subject.to_i).to eq(value)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
data/spec/instruction_spec.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'ronin/code/asm/instruction'
|
4
|
-
require 'ronin/code/asm/register'
|
5
|
-
require 'ronin/code/asm/immediate_operand'
|
6
|
-
require 'ronin/code/asm/memory_operand'
|
7
|
-
|
8
|
-
describe Ronin::Code::ASM::Instruction do
|
9
|
-
let(:register) { Ronin::Code::ASM::Register.new(:eax, 4) }
|
10
|
-
let(:immediate) { Ronin::Code::ASM::ImmediateOperand.new(0xff, 1) }
|
11
|
-
|
12
|
-
describe "#initialize" do
|
13
|
-
let(:name) { :mov }
|
14
|
-
let(:operands) { [immediate, register] }
|
15
|
-
|
16
|
-
subject { described_class.new(name,operands) }
|
17
|
-
|
18
|
-
it "must set the name" do
|
19
|
-
expect(subject.name).to eq(:mov)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "must set the operands" do
|
23
|
-
expect(subject.operands).to eq(operands)
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when given an Integer operand" do
|
27
|
-
let(:integer) { 0xff }
|
28
|
-
|
29
|
-
subject { described_class.new(name, [integer, register]) }
|
30
|
-
|
31
|
-
it "must wrap the operand to in a Ronin::Code::ASM::ImmediateOperand" do
|
32
|
-
expect(subject.operands[0]).to be_kind_of(Ronin::Code::ASM::ImmediateOperand)
|
33
|
-
expect(subject.operands[0].value).to eq(integer)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when given a nil operand" do
|
38
|
-
subject { described_class.new(name, [nil, register]) }
|
39
|
-
|
40
|
-
it "must wrap the operand to in a Ronin::Code::ASM::ImmediateOperand" do
|
41
|
-
expect(subject.operands[0]).to be_kind_of(Ronin::Code::ASM::ImmediateOperand)
|
42
|
-
expect(subject.operands[0].value).to eq(0)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "#width" do
|
48
|
-
subject { described_class.new(:mov, [immediate, register]) }
|
49
|
-
|
50
|
-
it "must return the maximum width of the operands" do
|
51
|
-
expect(subject.width).to eq(register.width)
|
52
|
-
end
|
53
|
-
|
54
|
-
context "when one of the operands does not define #width" do
|
55
|
-
subject { described_class.new(:mov, [:label, register]) }
|
56
|
-
|
57
|
-
it "must ignore them" do
|
58
|
-
expect(subject.width).to eq(register.width)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/spec/memory_operand_spec.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'ronin/code/asm/memory_operand'
|
4
|
-
require 'ronin/code/asm/register'
|
5
|
-
|
6
|
-
describe Ronin::Code::ASM::MemoryOperand do
|
7
|
-
let(:register) { Ronin::Code::ASM::Register.new(:eax, 4) }
|
8
|
-
|
9
|
-
describe "#initialize" do
|
10
|
-
it { expect(subject.base).to be_nil }
|
11
|
-
it { expect(subject.offset).to eq(0) }
|
12
|
-
it { expect(subject.index).to be_nil }
|
13
|
-
it { expect(subject.scale).to eq(1) }
|
14
|
-
|
15
|
-
it "must only accept nil and a Register for base" do
|
16
|
-
expect {
|
17
|
-
described_class.new(Object.new)
|
18
|
-
}.to raise_error(TypeError)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "must only accept Integers for offset" do
|
22
|
-
expect {
|
23
|
-
described_class.new(register,2.0)
|
24
|
-
}.to raise_error(TypeError)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "must only accept nil and a Register for index" do
|
28
|
-
expect {
|
29
|
-
described_class.new(register,0,Object.new)
|
30
|
-
}.to raise_error(TypeError)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "must only accept Integers for offset" do
|
34
|
-
expect {
|
35
|
-
described_class.new(register,0,nil,2.0)
|
36
|
-
}.to raise_error(TypeError)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#+" do
|
42
|
-
let(:operand) { described_class.new(register,4,register,2) }
|
43
|
-
|
44
|
-
subject { operand + 4 }
|
45
|
-
|
46
|
-
it "must add to offset" do
|
47
|
-
expect(subject.offset).to eq(8)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "must not change base, index or scale" do
|
51
|
-
expect(subject.base).to eq(operand.base)
|
52
|
-
expect(subject.index).to eq(operand.index)
|
53
|
-
expect(subject.scale).to eq(operand.scale)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#-" do
|
58
|
-
let(:operand) { described_class.new(register,4,register,2) }
|
59
|
-
|
60
|
-
subject { operand - 2 }
|
61
|
-
|
62
|
-
it "must subtract from offset" do
|
63
|
-
expect(subject.offset).to eq(2)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "must not change base, index or scale" do
|
67
|
-
expect(subject.base).to eq(operand.base)
|
68
|
-
expect(subject.index).to eq(operand.index)
|
69
|
-
expect(subject.scale).to eq(operand.scale)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#width" do
|
74
|
-
subject { described_class.new(register,10) }
|
75
|
-
|
76
|
-
it "must return the width of base" do
|
77
|
-
expect(subject.width).to eq(register.width)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
data/spec/os_spec.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/code/asm/os'
|
3
|
-
|
4
|
-
describe Ronin::Code::ASM::OS do
|
5
|
-
describe "SYSCALLS" do
|
6
|
-
subject { described_class::SYSCALLS }
|
7
|
-
|
8
|
-
let(:data_dir) { Ronin::Code::ASM::Config::DATA_DIR }
|
9
|
-
|
10
|
-
it { expect(subject).to be_kind_of(Hash) }
|
11
|
-
|
12
|
-
it "must load syscalls for :freebsd and :amd64" do
|
13
|
-
expect(subject[:freebsd][:amd64]).to eq(
|
14
|
-
YAML.load_file(
|
15
|
-
File.join(data_dir,'os','freebsd','amd64','syscalls.yml')
|
16
|
-
)
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "must load syscalls for :freebsd and :x86" do
|
21
|
-
expect(subject[:freebsd][:amd64]).to eq(
|
22
|
-
YAML.load_file(
|
23
|
-
File.join(data_dir,'os','freebsd','x86','syscalls.yml')
|
24
|
-
)
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "must load syscalls for :linux and :amd64" do
|
29
|
-
expect(subject[:linux][:amd64]).to eq(
|
30
|
-
YAML.load_file(
|
31
|
-
File.join(data_dir,'os','linux','amd64','syscalls.yml')
|
32
|
-
)
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "must load syscalls for :linux and :x86" do
|
37
|
-
expect(subject[:linux][:x86]).to eq(
|
38
|
-
YAML.load_file(
|
39
|
-
File.join(data_dir,'os','linux','x86','syscalls.yml')
|
40
|
-
)
|
41
|
-
)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe ".[]" do
|
46
|
-
context "when given :linux" do
|
47
|
-
it "must return #{described_class}::Linux" do
|
48
|
-
expect(subject[:linux]).to be(described_class::Linux)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when given :freebsd" do
|
53
|
-
it "must return #{described_class}::FreeBSD" do
|
54
|
-
expect(subject[:freebsd]).to be(described_class::FreeBSD)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "when given an unknown Symbol" do
|
59
|
-
let(:name) { :foo }
|
60
|
-
|
61
|
-
it do
|
62
|
-
expect {
|
63
|
-
subject[name]
|
64
|
-
}.to raise_error(ArgumentError,"unknown OS name: #{name.inspect}")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|