Python script to retrieve remote OS information without using nmap - nmap

I am trying to write a python script that can retrieve remote OS information (username, OS name, version, etc), like Nmap. Is it possible to do so without using Nmap ?

Of course it is possible but consider this, nmap guess OS type and version by checking remote system response and compare it with its signature database and it is not accurate.

Related

Hide postgres version from nmap scan

I'm setting up a server, with postgresql running as a service. I can use nmap to get current postgresql version
nmap -p 5432 -sV [IP]
It returns:
PORT STATE SERVICE VERSION
5432/tcp open postgresql PostgreSQL DB 9.3.1
Is there a way to hide the postgresql version from nmap scanning? I've searched but it's all about hiding the OS detection.
Thank you.
There's only one answer here: Firewall it.
If you have your Postgres port open, you will be probed. If you can be probed, your service can be disrupted. Most databases are not intended to be open like this to public, they're not hardened against denial-of-service attacks.
Maintain a very narrow white-list of IPs that are allowed to connect to it, and whenever possible use a VPN or an SSH tunnel to connect to Postgres instead of doing it directly. This has the additional advantage of encrypting all your traffic that would otherwise be plain-text.
You have a few options, but first understand how Nmap does it: PostgreSQL database server responds to a malformed handshake with an error message containing the line number in the source code where the error occurred. Nmap has a list of possible PostgreSQL versions and the line number where the error happens in that particular version. The source file in question changes frequently enough that Nmap can usually tell the exact version in use, or at least a range of 2 or 3 version numbers.
So what options do you have?
Do nothing. Why does it matter if someone can tell what version of PostgreSQL you are running? Keep it up to date and implement proper security controls elsewhere and you have nothing to worry about.
Restrict access. Use a firewall to limit access to the database system to only trusted hosts. Configure PostgreSQL to listen only on localhost if network communication is not required. Isolate the system so that unauthorized users can't even talk to it.
Patch the source and rebuild. Change PostgreSQL so that it does not return the source line where the error happened. Or just add a few hundred blank lines to the top of postmaster.c so Nmap's standard fingerprints can't match. But realize you'll have to do this every time there's a new version or security patch.

Do we have option to connect perl to MS access db in unix/linux platform?

I thinks windows os it is possible. But I'm not sure about unix/linux. Is there any option to do that. Any one tried before.
You access a MS Access file using ODBC via Perl perl DBI and perl DBD::ODBC using the following methods:
MDB tools (as other have said) which is free
Using an ODBC-ODBC Bridge commercial
Using a Microsoft Access ODBC Driver for Linux/Unix commercial
As current maintainer of DBD::ODBC I've had people report a lot of problems with MDB tools but if you free this is your only choice.
(2) requires you install a service on the windows machine where your MS Access file is located and then it uses the MS Access ODBC Driver. It provides a client ODBC driver for Linux and Unix which talks to the service on the Windows machine.
(3) requires direct access to the MS Access file i.e., you need to have it accessible from the Linux/Unix machine either by copying it to the local disk or accessing it via SMB (samba and file sharing from Windows machine).

PostgreSQL: Procedure or documentation for a strictly local installation

I am trying to do a local installation of a large but simple installation PostgreSQL 9.3.2 to hold about 14 GB of data, currently in a CSV file. This is my first attempt to install any database other than SQLite. The installer is asking me questions that I do not know how to answer and that seem inappropriate for an installation that I do not want to make available to the internet. I expect to be interacting with it through the R package RPostgreSQL. The database will contain primarily US Census data that is publicly available for free, and so not a tempting target. For instance, the installer asks me what port to use, and seems to require that I set a password. I prefer to set it up with no internet or remote accessibility at all, even from me.
Could someone tell me or point me toward documentation for producing a strictly local installation with minimal irrelevant hoops to jump through, both on installation and on use? I did a series of searches on variant of PostgreSQL & “install locally” or “local installation” or “create local database”, etc. but these were unproductive.
This will be on an ancient but lightly rebuilt Compaq laptop, Intel Core 2 Duo, Windows XP OS with SP3.
Any help folks could offer much appreciated.
If you're looking for an install that doesn't run a server and listen on TCP/IP, it isn't really possible, because PostgreSQL is a client/server database that (on Windows) communicates with clients solely over TCP/IP.
A "local only" install is one where the TCP/IP socket listens only on localhost, i.e. 127.0.0.1.
If you were really keen, you could not install the Windows service for the server at all, and just grab the binaries. To use PostgreSQL you would then have to initdb a new database directory, and start PostgreSQL when you wanted it with pg_ctl. See the user manual for details on these commands. When running, PostgreSQL would still be a server listening on a TCP/IP port, there's just no way around that on Windows.
On UNIX systems PostgreSQL can listen on a unix socket (a bit like a windows named pipe). This is not supported by PostgreSQL on Windows. Even then, it still has to run a server.
If you're looking for something like an embedded, on-demand, or in-memory PostgreSQL that runs out of the client library, there is no such thing.

Portable PostgreSQL for development off a usb drive

In order to take some development work home I have to be able to run a PostgreSQL database.
I don't want to install anything on the machine at home. Everything should run off the usb drive.
What development tools do you carry on your USB drive?
That question covers pretty much everything else, but I have yet to find a guide to getting postgresql portable. It doesn't seem easy if it's even possible.
So how do I get PostgreSQL portable? Is it even possible?
EDIT:
PostgreSQL Portable works. It's very slow on the usb-drive I have, but it works. I can't recommend doing constant development with it but for what I need it's great.
Perhaps if I pick up a full speed external drive I'll try out virtualization. Given the poor performance of just running the database off this drive, a full virtual OS running off of it would be unusable.
Here's how you can do this on your own:
http://www.postgresonline.com/journal/archives/172-Starting-PostgreSQL-in-windows-without-install.html
An alternate route would be to use something like VirtualBox and just install your development environment (database, whatever) on there.
There are 2 projects to try in 2014: http://sourceforge.net/projects/pgsqlportable/ and http://sourceforge.net/projects/postgresqlportable/?source=recommended.
I can't vouch for the second, but I'm using the first and it works right out of the box.
After unzipping using 7-zip (http://www.7-zip.org/download.html):
1) Run "start service without usuario.bat" ( english translation )
2) Then run "pgadmin3.bat"
The only minimal problem for me was that its in spanish. I've been able to change the language to english by following Change language of system and error messages in PostgreSQL. Using google translate the instructions are:
Description
This is a zip to automatically run postgresql 9.1.0.1 for windows. This version already has pgagent and pldebugger. To run must: 1) unzip
the zip 2) run the "start service without usuario.bat" found in the
pgsql directory within the folder you just unzipped. 3) Optional. If
you want to run the agent works postgresql (pgagent) should only run
the "start pgagent.bat" found in the pgsql directory inside the folder
you just unzipped. 4) Optional. To manage and / or develop the bd you
can run the pgadmin3.bat 5 files) Optional. To stop and / or restart
the server correctly use file "service without stopping usuario.bat"
usuario.bat or restart service without depending on the case.
Now option for Linux (file. Tar.gz). Postgresql portable Linux 9.2
Please use the tickets for your answer bugs.
Username: postgres Password: 123
Just a Note : on a new computer , to get pgadminIII working you may need to add a db. The settings are in attached screenshot.
Hope it helps.
I agree with virtualization solution, but maybe you can find useful this link from portable freeware collection, I have used this locally, not from usb though
1.download and extract : zip version
2.inside pgsql folder create data folder(put any name,I used 'data')
3.initalize data folder: c:\pgsql\bin\initdb.exe -D c:\pgsql\data -U postgres -W -E UTF8 -A scram-sha-256
4.to start/stop see next cmd code that I use (press any key inside it to stop)
c:\pgsql\bin\pg_ctl.exe -D c:\pgsql\data -l logfile start
pause
c:\pgsql\bin\pg_ctl.exe -D c:\pgsql\data stop
more info

How do I copy data from a remote system without using ssh or FTP Perl modules?

I have to write a Perl script to automatically copy data from remote server to my local system. The directory structure on remote systems is:
../log/D1/<date>.tar.gz
../log/D2/<date>.gz
../log/D3/<date>.tar.gz
../log/D4/<date>
and same on other server. I want to copy the data on local system in below format.
../log/S1/D1/<date>.tar.gz
../log/S1/D2/<date>.gz
../log/S1/D3/<date>.tar.gz
../log/S1/D4/<date>
and same for other servers i.e. S2, S3, etc
Also, no ssh supported Perl modules are available on remote server as well on local server and I dont have permission to install any Perl modules. The only good thing is that the connectivity is through password-less ssh keys.
Can anyone please suggest me any Perl code to get this done?
I believe you can access to shell command from perl.
So you can do this:
$cmd = "/usr/bin/scp remotefile localfile";
system $cmd;
NOTE: scp is secure-copy -- a buddy of ssh.
This does not require ssh-perl module but it require ssh support on both (which I have).
Hope this helps.
I started to suggest the scp command line program, but it seems that there's a CPAN module for that (no surprise). Check out Net::SCP.
By using scp on your client (where you can install new Perl modules) you can copy files without having to install any new software on the remote system. It just needs to have the ssh server running - which you've said it does.
I'd say stop trying to make life difficult for yourself and get the system to support the features you require.
Trying to develop for such a limited/ locked down platform is not going to be cost-effective in the long run - you'll develop stuff more slowly and it will have more bugs.
A little developer time is way more expensive than a decent hosted VM / hardware box.
Get a proper host, it will definitely save money (talk to your manager about this).
From your query above I understand that you don't have much permissions to install perl modules or do any changes which require administrative privileges. I love perl but to automate things like this you should use bash instead of perl. Below is the sample code I am using with password less ssh keys.
#!/bin/bash
DATE=`date`
BASEDIR="/basedir"
cd $BASEDIR
for HOST in S1 S2 S3
do
scp -q $HOST:$BASEDIR/D1/$DATE.tar.gz $HOST/D1/
echo "Data copy from $HOST done"
done
exit 0
You can use different date formats like date +%Y%m%d for current date in format YYYYMMDD. Also you can use this link to learn different date formats.
Hope this helps.
You may not be able to install anything in system-wide lib directories, but there is nothing preventing you from installing modules in a location to which you have write-access. See How do I keep my own module/library directory?
This creates no more of a security issue than allowing you to write scripts on this system in the first place.
So, go forth and install Net::SCP.
It sounds like you want rsync. You shouldn't have to do any programming at all.