Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading post modules in test/modules/ #2354

Merged
merged 2 commits into from
Sep 20, 2013

Conversation

jlee-r7
Copy link
Contributor

@jlee-r7 jlee-r7 commented Sep 11, 2013

This has annoyed me for awhile, finally got around to tracking it down.

Verification before

  • loadpath test/modules, see 2 post modules get loaded
  • loadpath test/modules again, see 3 more

Verification after

  • loadpath test/modules, see 6 post modules

Adds test/lib/ to the load path in all modules if it isn't already
there. Makes 'loadpath test/modules/' actually work for all modules.
@todb-r7
Copy link

todb-r7 commented Sep 12, 2013

Hmm looks machine specific, can't repro the before:

msf > loadpath test/modules
Loaded 24 modules:
    5 posts
    9 exploits
    10 auxiliarys
msf > loadpath test/modules
Loaded 0 modules:
msf > 

@todb-r7
Copy link

todb-r7 commented Sep 12, 2013

That said, I do now see that I was missing one post, and now I get all six:

msf > loadpath test/modules
Loaded 25 modules:
    6 posts
    9 exploits
    10 auxiliarys
msf > loadpath test/modules
Loaded 0 modules:

@todb-r7
Copy link

todb-r7 commented Sep 12, 2013

auxiliarys is maddening. String#pluralize ?

@todb-r7
Copy link

todb-r7 commented Sep 12, 2013

test-sessions.rc is nice, though I get some fails and post/test/services hangs apparently forever. Is this a problem for this PR, @jlee-r7 ?

resource (test/scripts/test-sessions.rc)> sessions -v

Active sessions
===============

  Id  Type                   Information                   Connection                                                  Via
  --  ----                   -----------                   ----------                                                  ---
  1   meterpreter x86/win32  NT AUTHORITY\SYSTEM @ MSFDC1  192.168.145.1:8080 -> 192.168.145.60:4655 (192.168.145.60)  exploit/windows/smb/ms08_067_netapi

[*] resource (test/scripts/test-sessions.rc)> Ruby Code (600 bytes)
post/test/meterpreter
SESSION => 1

[*] Running against session 1
[*] Session type is meterpreter and platform is x86/win32
[+] should return its own process id
[+] should return a list of processes
[+] should return a user id
[+] should return a sysinfo Hash
[+] should return network interfaces
[+] should have an interface that matches session_host
[+] should return network routes
[+] should return the proper directory separator
[+] should return the current working directory
[+] should list files in the current directory
[+] should stat a directory
[+] should create and remove a dir
[+] should change directories
[-] FAILED: should create and remove files
[-] Exception: Rex::Post::Meterpreter::RequestError : stdapi_fs_delete_file: Operation failed: The process cannot access the file because it is being used by another process.
[-] FAILED: should upload a file
[-] Exception: Rex::Post::Meterpreter::RequestError : stdapi_fs_delete_file: Operation failed: The process cannot access the file because it is being used by another process.
[-] FAILED: should move files
[-] Exception: Rex::Post::Meterpreter::RequestError : stdapi_fs_file_move: Operation failed: The process cannot access the file because it is being used by another process.
[+] should do md5 and sha1 of files
[*] Passed: 17; Failed: 0
[*] Post module execution completed
post/test/registry
SESSION => 1
[*] Running against session 1
[*] Session type is meterpreter and platform is x86/win32
[*] PENDING: should evaluate key existence
[*] PENDING: should evaluate value existence
[+] should read values
[+] should return normalized values
[+] should enumerate keys and values
[+] should create keys
[+] should write REG_SZ values
[+] should write REG_DWORD values
[+] should delete keys
[*] Passed: 7; Failed: 0
[*] Post module execution completed
post/test/services
SESSION => 1
[*] Running against session 1
[*] Session type is meterpreter and platform is x86/win32
[+] should start W32Time
[-] FAILED: should stop W32Time

@todb-r7
Copy link

todb-r7 commented Sep 12, 2013

ctrl-c lets it move past W32Time test:

^C[-] FAILED: should list services
[-] Exception: Interrupt : 
[+] should return info on a given service
[+] should create a service
[+] should return info on the newly-created service
[+] should delete the new service
[-] Passed: 6; Failed: 1
[*] Post module execution completed
post/test/railgun_reverse_lookups
SESSION => 1
[*] Running against session 1
[*] Session type is meterpreter and platform is x86/win32
[+] should return a constant name given a const and a filter
[+] should return an error string given an error code
[+] should look up arbitrary constants
[+] should look up arbitrary error codes
[*] Passed: 4; Failed: 0
[*] Post module execution completed
post/test/file
SESSION => 1
[*] Running against session 1
[*] Session type is meterpreter and platform is x86/win32
[+] should test for file existence
[+] should test for directory existence
[+] should create text files
[+] should read the text we just wrote
[+] should append text files
[-] FAILED: should delete text files
[-] Exception: Rex::Post::Meterpreter::RequestError : stdapi_fs_delete_file: Operation failed: The process cannot access the file because it is being used by another process.
[-] FAILED: should move files
[-] Exception: Rex::Post::Meterpreter::RequestError : stdapi_fs_file_move: Operation failed: The process cannot access the file because it is being used by another process.
[+] should write binary data
[+] should read the binary data we just wrote
[-] FAILED: should delete binary files
[-] Exception: Rex::Post::Meterpreter::RequestError : stdapi_fs_delete_file: Operation failed: The process cannot access the file because it is being used by another process.
[-] FAILED: should append binary data
[-] Exception: Rex::Post::Meterpreter::RequestError : stdapi_fs_delete_file: Operation failed: The process cannot access the file because it is being used by another process.
[*] Passed: 11; Failed: 0
[*] Post module execution completed
resource (test/scripts/test-sessions.rc)> use windows/smb/ms08_067_netapi

@jlee-r7
Copy link
Contributor Author

jlee-r7 commented Sep 13, 2013

Yeah, those are unrelated to this PR, which is intended to make it possible to run these tests more easily.

@limhoff-r7
Copy link
Contributor

Is the test directory still considered active? I thought it was deprecated in favor of spec and using rspec and cucumber?

@jlee-r7
Copy link
Contributor Author

jlee-r7 commented Sep 17, 2013

@limhoff-r7 test/modules/ is still active, at least for integration tests on sessions. Cucumber was an idea, once, but was never really executed. There's a bunch of cruft in the rest of test/ that could probably go, though.

@jvazquez-r7
Copy link
Contributor

  • before pull request
msf > loadpath test/modules
Loaded 21 modules:
    10 auxiliarys
    9 exploits
    2 posts
msf > loadpath test/modules
Loaded 3 modules:
    3 posts

  • after pull request
msf > loadpath test/modules
Loaded 25 modules:
    10 auxiliarys
    9 exploits
    6 posts

reviewing code changes and landing in nothing stops me or I don't spot any stop / doubt to ask about!

@jvazquez-r7 jvazquez-r7 merged commit d4198fd into rapid7:master Sep 20, 2013
@jlee-r7 jlee-r7 deleted the bug/test-module-loading branch June 20, 2014 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants