1. e4 e5
2. Nf3 Nf6
3. Nxe5 Nxe4
4. Qe2 Nf6
5. Nc6
Now the black Queen is DEAD. Black king is in check by White Queen and his queen is in attack by knight.To save check and his queen he can 5. .. Qe7 but then white can take the queen with knight at d6
Friday, May 23, 2008
PHP Hacking 1 = 1
'1 =1 ' is classic example of SQL injection attack. For the authentication some PHP GUI saves the user id and password in database. Generally a query something like this is used to validate the user given information:
SELECT * FROM users
WHERE user=''
AND passwd=''
A simple hacker like me ;-) can use SQL injection attack by specifying
User: Any
Password: OR 1 =1
This will allow me to give access to the site. Depending on the query you may need to try other variations like
Password: ') OR ('1=1')
The idea is to inject 1 =1 (which is true) in SQL statement such that the WHERE clause returns TRUE.
Happy Hacking...
SELECT * FROM users
WHERE user='
AND passwd='
A simple hacker like me ;-) can use SQL injection attack by specifying
User: Any
Password: OR 1 =1
This will allow me to give access to the site. Depending on the query you may need to try other variations like
Password: ') OR ('1=1')
The idea is to inject 1 =1 (which is true) in SQL statement such that the WHERE clause returns TRUE.
Happy Hacking...
Thursday, May 08, 2008
Putty passwordless ssh
putty accepts login and password as command line. So it can be easily used in batch to access machines without giving login and password.
putty host1 -l root -pw
I use it to the server which are build frequently. The problem with the server built frequently is that you cannot exchange keys as the keys will be deleted when the server is built again.
If you are using a linux box then sshpass can also be used for auto SSH.
Here is the batch script for windows lover
@echo off
if %1 == myserver goto myserver
goto default
:myserver
start C:\putty -ssh mercury -l -pw
exit
:default
start C:\putty -ssh %1 -l root -pw
exit
putty host1 -l root -pw
I use it to the server which are build frequently. The problem with the server built frequently is that you cannot exchange keys as the keys will be deleted when the server is built again.
Here is the batch script for windows lover
@echo off
if %1 == myserver goto myserver
goto default
:myserver
start C:\putty -ssh mercury -l
exit
:default
start C:\putty -ssh %1 -l root -pw
exit
Vim Ctrl-r Ctrl-w
Vim Ctrl-r Ctrl-w can be used to read the word under the cursor. It is useful if you want to edit files under the cursor.
:e \C-v \C-r \C-v\C-w \C-v
I know you can use gf to go the file. But just wanted to do it using one key.:-)
:e \C-v \C-r \C-v\C-w \C-v
I know you can use gf to go the file. But just wanted to do it using one key.:-)
Bind command
bind command can be used to bind your key strokes with the commands. I use it frequently to access my cleartool commands.
after editing a file using vi. You can check the difference with the predecessor or the version tree for the file using key-strokes Alt-d or Alt-t
bind -x '"\M-d"':'cleartool diff -pred -g -options "-b" $_ &'
bind -x '"\M-t"':'cleartool lsvtree -g $_ &'
after editing a file using vi. You can check the difference with the predecessor or the version tree for the file using key-strokes Alt-d or Alt-t
bind -x '"\M-d"':'cleartool diff -pred -g -options "-b" $_ &'
bind -x '"\M-t"':'cleartool lsvtree -g $_ &'
Thursday, February 07, 2008
Handy RPM commands
# Unpackage an ISO file.
rpm2cpio <> | cpio -idmv
# Extracting the scripts from the rpm
rpm -qp --scripts <> >> /tmp/scripts
# Command to find if any of the files delivered by an RPM has changed.
rpm --verify
rpm2cpio <
# Extracting the scripts from the rpm
# Command to find if any of the files delivered by an RPM has changed.
rpm --verify
wdl
GNU working directory list is an open source utlity to easily move between the working directories. You can even set CDPATH to move effectively between the directores. But take care setting CDPATH can also cause make command to fail, if you have a top-level make file which cd into sub-dirs and does a make.
Friday, December 28, 2007
Screen Command
Unix Screen command is an indespensable command. Once you know it you cannot live without it. It is window manager. Just try it and you will find it mind blowing.
A new screen can be created using
screen.
Ctrl-A c - Create new window
Ctrl-A A - Name a window
Ctrl-A " - Show all windows.
Ctrl-A S split window.
Ctrl-A tab to move to the next window.
A new screen can be created using
screen.
Ctrl-A c - Create new window
Ctrl-A A - Name a window
Ctrl-A " - Show all windows.
Ctrl-A S split window.
Ctrl-A tab to move to the next window.
Putty Title
Putty Title can be easily modified using the function wt.
wt ()
{
echo -n "^[]2;${@}^G"
# In all of these, ^[ is really the "escape" character.
# You put it into a file using vi, by typing control-V and then hitting the Escape key.
# Likewise, ^G is the control-G# character. Again, hit control-V
# then hit control-G
}
The link 'http://www.unix.com/unix-dummies-questions-answers/35518-name-path.html'
wt ()
{
echo -n "^[]2;${@}^G"
# In all of these, ^[ is really the "escape" character.
# You put it into a file using vi, by typing control-V and then hitting the Escape key.
# Likewise, ^G is the control-G# character. Again, hit control-V
# then hit control-G
}
The link 'http://www.unix.com/unix-dummies-questions-answers/35518-name-path.html'
Friday, April 06, 2007
Wednesday, January 31, 2007
Word macro to export comments
' This macro will export all the comments in the word doc to a new word doc.
' U can save the word doc as .txt.
' Change the extension to .csv
' Open the doc with excel and u have exported your comments to excel
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
For Each cmt In ActiveDocument.Comments
s = s & cmt.Initial & cmt.Index & "," & cmt.Range.Text & vbCr
Next
Set doc = Documents.Add
doc.Range.Text = s
End Sub
' U can save the word doc as .txt.
' Change the extension to .csv
' Open the doc with excel and u have exported your comments to excel
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
For Each cmt In ActiveDocument.Comments
s = s & cmt.Initial & cmt.Index & "," & cmt.Range.Text & vbCr
Next
Set doc = Documents.Add
doc.Range.Text = s
End Sub
Word macro for requirement table
Need word macro to parse a doc and get all the requirements in one table
Friday, January 05, 2007
MSWORD: Macro to add cross reference
Sub CreateCR()
' CreateCR Macro
' Macro recorded 1/5/2007 by Jay
' This macro converts selection copy to a cross reference - numbered item
Selection.Copy
Dim crossref
crossref = Selection
'MsgBox (crossref)
Dim pNumberedItem
pNumberedItem = ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem) For i = 1 To UBound(pNumberedItem)
'MsgBox (pNumberedItem(i))
If Selection = Trim(pNumberedItem(i)) Then
Selection.InsertCrossReference ReferenceType:="Numbered item", _ ReferenceKind:=wdNumberNoContext, ReferenceItem:= i, _
InsertAsHyperlink:=True, IncludePosition:=False
Exit For
End If
Next i
End Sub
' CreateCR Macro
' Macro recorded 1/5/2007 by Jay
' This macro converts selection copy to a cross reference - numbered item
Selection.Copy
Dim crossref
crossref = Selection
'MsgBox (crossref)
Dim pNumberedItem
pNumberedItem = ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem) For i = 1 To UBound(pNumberedItem)
'MsgBox (pNumberedItem(i))
If Selection = Trim(pNumberedItem(i)) Then
Selection.InsertCrossReference ReferenceType:="Numbered item", _ ReferenceKind:=wdNumberNoContext, ReferenceItem:= i, _
InsertAsHyperlink:=True, IncludePosition:=False
Exit For
End If
Next i
End Sub
Sunday, December 31, 2006
Windows: Adding button to IE
run gpedit.msc
go to Windows Settings InternetExplorerMaintenance
Browser User Interface Browser ToolBar Customizations
go to Windows Settings InternetExplorerMaintenance
Browser User Interface Browser ToolBar Customizations
Thursday, December 28, 2006
Windows: BookMarkelet to fill taxi requests
javascript:function jay(){var F = document.forms;var x=F[0].PURPOSE; x.options[x.selectedIndex].text='Late Stay';var y=F[0].LOC_TYPE; y.options[y.selectedIndex].text='Plot - 17';F[0].CHARGENO.value = 'STKL002',F[0].TO_PLACE.value='Gurgaon Patel Nagar',F[0].l_tele_no.value='9818203631';} jay();
You can find more information about book markelets from wikipedia
You can find more information about book markelets from wikipedia
VIM: Auto commenting for function closing braces
You can use the following code to perform auto commenting. Put this in your .vimrc file.
This script will add the following comment after }//
}// end
" abbrevation for doing commenting at end of functin curly bracket end "}"
" use }// to comment the code
iab }// ^[:call CurlyBracket()^MA
function CurlyBracket()
let l:my_linenum = line(".")
let l:linenum = searchpair('{', '', '}', 'bW')
let l:line = getline(l:linenum - 1)
let l:str = strpart( line, 4 )
sil exe ":" . l:my_linenum
sil exe "normal a} // end " . str
endfunction
This script will add the following comment after }//
}// end
" abbrevation for doing commenting at end of functin curly bracket end "}"
" use }// to comment the code
iab }// ^[:call CurlyBracket()^MA
function CurlyBracket()
let l:my_linenum = line(".")
let l:linenum = searchpair('{', '', '}', 'bW')
let l:line = getline(l:linenum - 1)
let l:str = strpart( line, 4 )
sil exe ":" . l:my_linenum
sil exe "normal a} // end " . str
endfunction
Tuesday, December 26, 2006
VIM: vimrc function to set file name
This function replaces the existing file name with the name of the file stored in register %.
The file should have the file name after "Module" word for this function to work properly.
function! ReadFileName()
let l:linenum = search("^// *[Mm]odule","w")
let l:filename = getreg("%")
let l:newline = '// Module : '.filename
sil exe ":call setline( linenum, newline)"
endfunction
The file should have the file name after "Module" word for this function to work properly.
function! ReadFileName()
let l:linenum = search("^// *[Mm]odule","w")
let l:filename = getreg("%")
let l:newline = '// Module : '.filename
sil exe ":call setline( linenum, newline)"
endfunction
Subscribe to:
Posts (Atom)