I am automating Nessus(vulnerability scanner) scans using metasploit-framework. User enters target(url or ip address), name, description in a file and then executes start.sh.
Start.sh file reads user preferences(name,target,description and then set their values in shell variables) from that file and also contains commands to start msfconsole and then authenticate with nessus and configure a new scan and then waits for scan completion.
start.sh
service nessusd start
msfconsole
#load nessus plugin
load_nessus
#authenticate with nessus
nessus_connect username:password@localhost:8834
#configure new scan
nessus_scan_new UUID $name $description $target
Problem here is that in msfconsole I am unable to catch shell variables and also unable to declare shell variables in msfconsole.
Proof # 1 : setting shell variable in msfconsole
msf5> name="ScanExample.com"
[-] Unknown command: name=ScanExample.com.
Proof # 2 : set shell variable in bash terminal and then access in msfconsole name="ScanExample.com"
msf5> echo $name
(shows nothing)
msf5> nessus_scan_new UUID $name $description $target
(it configures new scan but sets their values as with $ sign. means target=$target that makes no sense)
Proof # 3 :
msf5> set name ScanExample.com
name => ScanExample.com
msf5> get name
name => ScanExample.com
But in this case how to embed this variable with this command nessus_scan_new UUID $name $description $target
Any ideas how to achieve the solution....Thanks in advance