NMAP NSE call shell script - nmap

Is it possible to call external unix programs from nmap nse scripts just like with system(), exec() from php or C?
I already tried to use cmd, cmd.local.
Thanks!

Yes, you can use Lua's os.execute function to do this.

Related

ipython magic/macro/alias guidance for invoking shell and dispatching result

(Note: I have plenty of python and unix shell experience, but fairly new to ipython -- using 7.5)
I'm trying to replicate a UNIX shell function that I use all the time, so that it works in the ipython shell.
The requirement is that I want to type something like to myproj, and then have ipython process the resulting text by doing a cd to the directory that comes back from to. (This is a quick-directory-change utility I use in unix)
The way it works in unix is that a shell function invokes an external command, that command prints its result to stdout, and the shell function then invokes the internal cd to the target dir.
I've been trying to wrap my head around %magic and macros and aliases in ipython, but so far I don't see how to get this done. Any ideas?

Open SecureCRT using perl

I am using secureCRT. I want to automate secureCRT using perl. I intend to open the secureCRT, enter hostname,username and password and then execute a command in secureCRT. Is there any perl object to work with secureCRT.
Is there any command like
Win32::OLE (SecureCRT.Application)
for perl
I am unable to find any perl documentation for using secureCRT
Assuming you want to interact with a server that has a ssh daemon running, I suggest you to have a look at Net::SSH::Perl and skip trying to use SecureCRT from Perl.
Hope this helps
Besides using some Perl module for SSH (i.e. Net::SSH2 or Net::SSH::Any), there is also PAC Manager, a connection manager similar to SecureCRT but written and scriptable in Perl.

In Perl CGI, how can I use UNIX commands?

I'm trying to run ssh, mkdir from a Perl CGI script. It's not working. But in normal Perl script, it is working fine. Can any one tell me how to run commands in a Perl CGI script?
If you're running this script via a webserver, chances are the active user (e.g. "nobody", "www", etc) may not have the necessary privileges to execute commands like mkdir and ssh. If so, that is not something that perl can fix. You can test who the active user is with something like:
print "The active user is: ", `whoami`;
It is also a security concern, to have your web user privileges set to create files and perform commands.
system() or popen() are probably what you're looking for, if you're feeling dirty I think you can use back ticks too.
Do you need to run unix commands? Perl has a built-in mkdir, and there are modules to handle SSH. Normally a CGI process is going to have limited capabilities or access to the system. The more you can do in Perl the better.

Is there a CPAN Perl module to find total/used/free memory on a host (without running command line through a system() call)?

Is there a CPAN Perl module which provides total/used/free memory (like vmstat does) on a host without running a command line through a system() call to get the info?
Ideally it should be cross-platform (Linux and Solaris) though please provide Linux or Solaris-only ones as well.
Looks like Sys::MemInfo is what I needed.
It is implemented in XS, using <sys/sysinfo.h> for Linux and <sys/stat.h> / <sys/swap.h> for Solaris.
Try the Sys::Statistics::Linux distrubition for linux.

invoking commands on Unix from Windows power shell

Is this possible ?, someone has suggested that I migth be able to do via ssh, essentially run a command on Unix pipe the output to a file get it back and then perform some action in the invoking Power Shell script.
Well, you can use tools like plink to execute a command via ssh on a remote server. Also you don't need to write the result to a file; you can simply assign it to a variable:
$output = plink ...
With Win32-OpenSSH you can execute commands over SSH. See Win32-OpenSSH Examples.
It is possible!
Have a look at this GitHub repository for all of the UNIX commands that have been compiled to run on Windows. Then, you can run both PowerShell and UNIX commands from PowerShell.