2014-08-01

How to Use SqlDependency

1. Start Service Broker for the DB

USE Master
ALTER DATABASE [DBName] SET ENABLE_BROKER;
//If there are transactions pending in this db, use following command
ALTER DATABASE [DBName] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;

2. Assign GUEST rights for QueryNotificationService

USE [DBName]
GRANT SEND ON SERVICE::
[http://schemas.microsoft.com/SQL/Notifications/QueryNotificationService]
TO Guest

Note For SqlDependency class
1. Each time the OnChange event fired, need to re-subscript

Note For SELECT Statement:
1. The column name can't use *
2. with (nolock) is not allowable
3. TableName need to use dbo.TableName

Supported SELECT Statements Reference
http://msdn.microsoft.com/en-us/library/ms181122.aspx

2014-04-13

PostgreSQL On Kali Linux

HOW TO START POSTGRESQL SERVICE & METASPLOIT SERVICES.
  • Command Used : services postgresql start && services metasploit start .
  • See the below image for the response -

Description : In this command we start both the services together .
  1. First service we start is postgresql .
  2. And second service we start is metsploit .
Note : You can also start these services one-by-one also .
OPEN METASPLOIT FRAMEWORK 
METASPLOIT FRAMEWORK OPENED
NOW CHECK ALL THE DATABASE BACKEND COMMANDS
COMMAND USED 
  • Description : After using help command it will display all the commands that are used in metasploit framework but we are only  cover Database Backend Commands .The above image shows all the commands .
CHECKING DATABASE STATUS 
  • Now once we start the postgresql and metasploit services , lets see is our database is connected to msf or not . 
  • Command Used : db_status 
Description : It shows  that our database( postgresql ) is connected to msf3( metasploit framework3 ).
PERFORM NMAP SCAN WITHIN METASPLOIT FRAMEWORK 
TARGET 1 : METASPLOITABLE 
TARGET 2: WINDOWS XP 
HOSTS COMMAND 
  • Now after scanning 2 targets lets use the command hosts 
  • Command Used : hosts
Description :We scan  two targets ( Metasploitable , windows xp )And when you use the hosts command , it will display the list of hosts you scan.
HOST HELP COMMAND 
  • If you want something more about hosts command  then use the following command .
  • Command Used : hosts -h.
  • See the below image for more details- 
EXAMPLES
EXAMPLE 1 : SHOW ONLY THOSE HOST WHICH ARE UP 
  • This command only shows those host which are running on the network .
  • See the below image for more details -
EXAMPLE 2 : SEARCH HOSTS 
  • COMMAND : hosts -S < host-ip>
  • This command helps you when there is a long list and you have to filter single ip .
  • See the below example for more details - 
EXAMPLE 3 : ONLY SHOW THE GIVEN COLUMNS 
OUTPUT
DELETE HOSTS
SERVICES 
Services help 

  • Examples1 : It will display all the running services .
  • See the below image for more details -
Example 2 : 

EXAMPLE 3 : Only show the given columns

EXAMPLE 4  : SEARCH FOR A LIST OF SERVICE NAMES 


EXAMPLE 5 : ONLY SHOW TCP UDP SERVICES 


EXAMPLE 6 : SEARCH FOR A LIST OF PORTS 


NOTES COMMAND : List all the notes in the database

NOTES HELP COMMAND 




WORKSPACE : DATABASE WORKSPACES


DATABASE EXPORT COMMAND 


DATABASE DISCONNECT COMMAND 
  • To disconnect database , use the db_disconnect command .
  • See the below image for more details -
  • And to check the database status , use the db_status command .



Source : http://www.hackingdna.com/Description.aspx?ItemHeaderId=7C91C7B8-10C3-49F6-8BBA-AEA39748959F#.U0pq-fmSxin

FIX METASPLOIT “DATABASE NOT CONNECTED OR CACHE NOT BUILT”

After open msfconsole, enter db_status but saw there is no connection to datablase.

Stpe 1: Start up PostgreSQL and Metasploit services

#service postgresql start
#service metasploit start

Stpe 2: Build the cache

msf > db_rebuild_cache

WPF WindowChrome for custom window style

Target - .NetFrameWork 4.5

xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework"

<Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <WindowChrome ResizeBorderThickness="5"
                              CaptionHeight="40"
                              GlassFrameThickness="-1"
                               />
            </Setter.Value>
        </Setter>


when the WindowChrome class is applied to our window, it automatically sets WindowStyle="None"and ResizeMode to "NoResize"



Start service at boot on Kali Linux

Apache and mysql are installed by default in Kali Linux. They can be accessed through the Kali Linux menu in Applications. To start apache web server click the menu entry at "Applications > Kali Linux > System Services > HTTP > apache2 start". Similary to start mysql click MySQL > mysql start.
However starting services manually everytime is a waste of time and its better to get them to start automatically at boot.
To configure services like apache, mysql etc to start automatically at bootup just execute the following simple commands.

Apache

The following command will configure apache to start at bootup.
root@kali:~# update-rc.d apache2 enable
update-rc.d: using dependency based boot sequencing

Mysql

The following command will configure mysql to start at bootup.
root@kali:~# update-rc.d mysql enable
update-rc.d: using dependency based boot sequencing

Postgresql

Postgresql is used by metasploit for caching data. Therefore its better to get it started at bootup as well. Command is similar to the above ones.
root@kali:~# update-rc.d postgresql enable
update-rc.d: using dependency based boot sequencing

TOR

Tor, the great anonymity network is also a must for hackers. So it should always be at service when you are hacking inside Kali.
root@kali:~# update-rc.d tor enable
update-rc.d: using dependency based boot sequencing

Test configuration

The configuration is now done. Now reboot kali. After it boots up, check the status of the services by running the following commands.
root@kali:~# service apache2 status
Apache2 is running (pid 2072).
Check status of postgresql
root@kali:~# service postgresql status
Running clusters: 9.1/main
So all services should startup themselves at boot up. If there are any more services you need to startup, configure them using the update-rc.d command, and they should work.