
theall at tenablesecurity
Apr 10, 2007, 6:32 PM
Post #2 of 2
(1347 views)
Permalink
|
On 04/10/07 13:20, jfvanmeter [at] comcast wrote: > Hello, below is the code that i' think would verify the version of > dreamweaver installed on a remote host. Would someone point out any > mistakes or areas that I an improve on. I'll give it a shot. I haven't looked at this particular app so the general approach could be completely wrong. If so, you man want to if it's possible to pull the version info out of a registry key or by reading / parsing a file of some type. > script_id(99999); We recommend using script ids in the range 60000 - 62000 for custom plugins. > script_copyright(english:"This script is Copyright (C) 2007 Tenable Network Security"); Aw, shucks, you give us too much credit! > script_dependencies("smb_hotfixes.nasl", "opera_installed.nasl"); Not sure why you have 'opera_installed.nasl' here; it's not required. > include("smb_func.inc"); > include("smb_hotfixes.inc"); These won't work if you intend to submit this as they're not part of the GPL feed. > # Determine its version from the executable itself. > share = ereg_replace(pattern:"^([A-Za-z]):.*", replace:"\1$", string:path); > exe = ereg_replace(pattern:"^[A-Za-z]:(.*)", replace:"\1\dreamweaver.exe", string:path); 'path' is uninitialized at this point. I don't know off-hand how Dreamweaver works, but typically plugins pull this info from a registry key, under HKLM. Take a look at quicktime_installed.nasl for a basic example. > fh = CreateFile( > file:exe, > desired_access:GENERIC_READ, > file_attributes:FILE_ATTRIBUTE_NORMAL, > share_mode:FILE_SHARE_READ, > create_disposition:OPEN_EXISTING > ); After this, typically you make sure that 'fh' is not null and then call GetFileVersion() to get the file version info ('ver') from the specified file; otherwise, 'ver' will remain uninitialized. > # Check the version > if ( > !isnull(ver) && > ( > ver[0] < 8 || > (ver[0] == 8 && ver[1] == 0 && ver[2] < 9) Are you worried about versions before 8.0.9 or 8.0.2? The code checks for the first yet your description talks about the second. > if (info) { > report = strcat( > desc, > '\n\n', > 'Plugin output :\n', > '\n', > info > ); Where do you set 'info'? I'd probably do away with this conditional check and just issue the report, replacing 'info' in it with some text saying what version you found and maybe the installation path. If your tastes run towards less verbosity, just call: security_hole(port); and it will use the text you specified for 'desc'. And lastly, you're missing a closing brace, at least in the copy you posted, as well as calls to RegCloseKey() to close the hklm key, to CloseFile() to close the file handle, and NetUseDel() when everything is done. George -- theall [at] tenablesecurity _______________________________________________ Plugins-writers mailing list Plugins-writers [at] list http://mail.nessus.org/mailman/listinfo/plugins-writers
|