/* Port Scanner
* http://ProjectGhostt.com
* FreckleS
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
namespace Port_Scanner
{
class Program
{
static void Main(string[] args)
{
// Scan specific port
int port = 135;
if (TestPort(port) == true)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Port {0} is OPEN!", port);
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Port {0} is CLOSED!", port);
}
// Scan a range of ports
for (int i = 1; i < 1000; i++) // for (int i = startPort; i < stopPort; increment port)
{
if (TestPort(i) == true)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Port {0} is OPEN!", i);
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Port {0} is CLOSED!", i);
}
}
}
static bool TestPort(int port)
{
try
{
TcpClient tcp = new TcpClient("127.0.0.1", port);
if (tcp.Connected == true)
{
return true;
}
}
catch
{
return false;
}
return false;
}
}
}
BidVertiser
Thursday, October 28, 2010
[C#] Port Scanner
Wednesday, October 27, 2010
Capturing the Desktop Screen with the Mouse Cursor Image (Rashid.Mahmood )
public static Bitmap CaptureDesktopWithCursor()
{
int cursorX = 0;
int cursorY = 0;
Bitmap desktopBMP;
Bitmap cursorBMP;
Bitmap finalBMP;
Graphics g;
Rectangle r;
desktopBMP = CaptureDesktop();
cursorBMP = CaptureCursor(ref cursorX, ref cursorY);
if(desktopBMP != null)
{
if (cursorBMP != null)
{
r = new Rectangle(cursorX, cursorY,
cursorBMP.Width, cursorBMP.Height);
g = Graphics.FromImage(desktopBMP);
g.DrawImage(cursorBMP, r);
g.Flush();
return desktopBMP;
}
else
return desktopBMP;
}
return null;
}
static Bitmap CaptureCursor(ref int x, ref int y)
{
Bitmap bmp;
IntPtr hicon;
Win32Stuff.CURSORINFO ci = new Win32Stuff.CURSORINFO();
Win32Stuff.ICONINFO icInfo;
ci.cbSize = Marshal.SizeOf(ci);
if(Win32Stuff.GetCursorInfo(out ci))
{
if (ci.flags == Win32Stuff.CURSOR_SHOWING)
{
hicon = Win32Stuff.CopyIcon(ci.hCursor);
if(Win32Stuff.GetIconInfo(hicon, out icInfo))
{
x = ci.ptScreenPos.x - ((int)icInfo.xHotspot);
y = ci.ptScreenPos.y - ((int)icInfo.yHotspot);
Icon ic = Icon.FromHandle(hicon);
bmp = ic.ToBitmap();
return bmp;
}
}
}
return null;
}
// ssWithMouseViewer is the PictureBox control
private void Display(Bitmap desktop)
{
Graphics g;
Rectangle r;
if(desktop != null)
{
r = new Rectangle(0,0,ssWithMouseViewer.Width,
ssWithMouseViewer.Height);
g = ssWithMouseViewer.CreateGraphics();
g.DrawImage(desktop,r);
g.Flush();
}
}
{
int cursorX = 0;
int cursorY = 0;
Bitmap desktopBMP;
Bitmap cursorBMP;
Bitmap finalBMP;
Graphics g;
Rectangle r;
desktopBMP = CaptureDesktop();
cursorBMP = CaptureCursor(ref cursorX, ref cursorY);
if(desktopBMP != null)
{
if (cursorBMP != null)
{
r = new Rectangle(cursorX, cursorY,
cursorBMP.Width, cursorBMP.Height);
g = Graphics.FromImage(desktopBMP);
g.DrawImage(cursorBMP, r);
g.Flush();
return desktopBMP;
}
else
return desktopBMP;
}
return null;
}
static Bitmap CaptureCursor(ref int x, ref int y)
{
Bitmap bmp;
IntPtr hicon;
Win32Stuff.CURSORINFO ci = new Win32Stuff.CURSORINFO();
Win32Stuff.ICONINFO icInfo;
ci.cbSize = Marshal.SizeOf(ci);
if(Win32Stuff.GetCursorInfo(out ci))
{
if (ci.flags == Win32Stuff.CURSOR_SHOWING)
{
hicon = Win32Stuff.CopyIcon(ci.hCursor);
if(Win32Stuff.GetIconInfo(hicon, out icInfo))
{
x = ci.ptScreenPos.x - ((int)icInfo.xHotspot);
y = ci.ptScreenPos.y - ((int)icInfo.yHotspot);
Icon ic = Icon.FromHandle(hicon);
bmp = ic.ToBitmap();
return bmp;
}
}
}
return null;
}
// ssWithMouseViewer is the PictureBox control
private void Display(Bitmap desktop)
{
Graphics g;
Rectangle r;
if(desktop != null)
{
r = new Rectangle(0,0,ssWithMouseViewer.Width,
ssWithMouseViewer.Height);
g = ssWithMouseViewer.CreateGraphics();
g.DrawImage(desktop,r);
g.Flush();
}
}
Stream.Read Method
When overridden in a derived class, reads a sequence of bytes from the
current stream and advances the position within the stream by the number of bytes read.
public abstract int Read( byte[] buffer, int offset, int count )
Stream.Write Method
When overridden in a derived class, writes a sequence of bytes to the
current stream and advances the current position within this stream by
the number of bytes written.
const int size = 4096; byte[] bytes = new byte[4096]; int numBytes; while((numBytes = input.Read(bytes, 0, size)) > 0) output.Write(bytes, 0, numBytes);
Messenger Sending Unlimited Nudges
Sending Unlimited Nudges
Update: This trick no longer works in MSN Messenger 7.5 or newer!
Nudges are a new feature in MSN Messenger 7 which are used to get your contact's attention, similar to Yahoo's 'buzz' feature, if not exactly the same! With this little trick you can send unlimited nudges to a contact, but keep in mind that contacts who have their status set to busy, will not see or hear the effect of an MSN Nudge, or they could have simply disabled the Nudge feature on their computer. Anyway, on to the trick...
To send unlimited Nudges in MSN Messenger in 3 easy steps:
- Set your status to Busy in MSN Messenger
- Open a conversation with the contact you wish to Nudge Bomb
- Click the Nudge button repeatedly, as many times as you like!
Saturday, October 23, 2010
A Beginner's Simple Encryption Tutorial / Example
// Adam Boulfoul - "A Beginner's Simple Encryption Tutorial / Example" chebby_shabby@hotmail.com
/////////////////////////////////////////////////////////////////////////////////////////////////
// This is not an "uncrackable" type of encryption but once you can understand the basics of
// this type of file encryption you CAN make better ones than me. This is just a quick example
// of basic encryption. Highly commented to help beginners.
/////////////////////////////////////////////////////////////////////////////////////////////////
// Before we start:
// What this basic program does is simply getting a byte from a file then adding 25 to it
// (ofcouse you can change it to whatever you like).
/////////////////////////////////////////////////////////////////////////////////////////////////
// If you have any questions, my e-mail is above
/////////////////////////////////////////////////////////////////////////////////////////////////
#include // We need this for input and output to the user
#include // This is the header to read or write files
#include // We only need this to delete a file using remove()
// As mentioned abode, we simply add 25 to a byte, change this to whatever you like.
#define ENCRYPTION_FORMULA (int) Byte + 25
// The decryption formula is the opposite to encryption formula, every "+" is a "-"
#define DECRYPTION_FORMULA (int) Byte - 25
///////////////////////////////////////////////////////////////////////////////////////////
// TIP: Everytime you see ENCRYPTION_FORMULA ot DECRYPTION_FORMULA mensioned, highlight it
// then press on definition and it will bring you up here! (Only on Visual C++)
///////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Our main function, put this in your program, FILENAME is the file to encrypt
// and NEW_FILENAME is the new location of the encrypted file
/////////////////////////////////////////////////////////////////////////////////
int Encrypt (char * FILENAME, char * NEW_FILENAME)
{
ifstream inFile; // This is the file that we're going to encrypt and read
ofstream outFile; // Once we encrypt the file, this is it's new location
char Byte; // This is the FILENAME's byte, we'll add 25 to this later
///////////////////////////////////////////////////////////////
// Before we continue:
// ios:: in - Used for reading a file
// ios::out - Used for writing a file
// ios::binary - Used for reading or writing binary files
///////////////////////////////////////////////////////////////
inFile.open(FILENAME, ios::in | ios::binary); // We read this file in binary mode
outFile.open(NEW_FILENAME, ios::out | ios::binary); // And we write the file in binary mode
// eof() stands for End Of File, so while we are still reading the file, continue
while(!inFile.eof())
{
// Remember we need to change a byte so we add 25 to it
char NewByte;
//////////////////////////////////////////////////
// NOTE: Only use the .put() and .get() in loops
// because it only reads 1 Byte at a time!
//////////////////////////////////////////////////
// Out old byte is recieved from the file
Byte = inFile.get();
// If the file that we are reading has an error, turn 0
if (inFile.fail())
return 0;
//Remember our Encryption Formula above?
//Our new byte is recieved from it, see above
NewByte = ENCRYPTION_FORMULA;
// This simple puts the new byte, into the new file!
outFile.put(NewByte);
}
// We have to be neat so we close both the file that we're reading
// and the file that we're writing
inFile.close(); // (File to read)
outFile.close(); // (File to write)
return 1; // Success!
}
///////////////////////////////////////////////////////////////////////////////
// What's the point of encrypting a file if you can't decrypt it?
// If you're wondering why this is not commented it's because I've already
// explained everything above, notice that everything is the same except for
// two lines!
///////////////////////////////////////////////////////////////////////////////
int Decrypt (char * FILENAME, char * NEW_FILENAME)
{
ifstream inFile;
ofstream outFile;
char Byte;
inFile.open(FILENAME, ios::in | ios::binary);
outFile.open(NEW_FILENAME, ios::out | ios::binary);
while(!inFile.eof())
{
char NewByte;
Byte = inFile.get();
if (inFile.fail())
return 0;
/////////////////////////////////////////////////////
NewByte = DECRYPTION_FORMULA; // New Line! We just change the ENCRYPTION_FORMULA
// to DECRYPTION_FORMULA, see above
/////////////////////////////////////////////////////
outFile.put(NewByte);
}
inFile.close();
outFile.close();
return 1;
}
///////////////////////////////////////////////////////////////////////
// WARNING: If you choose to decrypt a file that it already decrypted
// then the file would be encrypted!
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// To use the functions in your program (doesn't have to be a DOS program),
// copy the 2 functions above, this is just an example, in the example I'm
// encrypting
///////////////////////////////////////////////////////////////////////////////////
int main()
{
///////////////////////////////////////////////////////////////////
// The functions can be used in not only DOS programs
// Since this is an example, I'll show you how to use them
///////////////////////////////////////////////////////////////////
char EncFile[200]; // This is the string for the file to be encrypted
char NewEncFile[200]; // This is the new location of the encrypted file
char DecFile[200]; // This is the string for the file to be decrypted
char NewDecFile[200]; // This is the new location of the decrypted file
int Choice; //The user's choice variable (1 = Encrypt 2 = Decrypt)
// In case you didn't know, all these "cout" just display a message
// Cin tells the user to input something
cout << "NOTE: You must encrypt the file with the same file extension!"<
cout << "Enter 1 to Encrypt / 2 to Decrypt"<
cin >> Choice; // In this case, our input is the user's choice
switch(Choice)
{
case 1: // Did the user choose to encrypt a file?
cout << "Enter the current Filename: ";
cin >> EncFile; // The user's input for the current file to be encrypted
cout << "Enter the new Filename: ";
cin >> NewEncFile; //The user's input for the new location of the encrypted file
Encrypt(EncFile, NewEncFile); /*********** ENCRYPT FUNCTION ************/
break;
case 2: // Or did the user choose to decrypt a file?
cout << "Enter the current Filename: ";
cin >> DecFile; //Already explained but with the decrypted file this time!
cout << "Enter the new Filename: ";
cin >> NewDecFile;
Decrypt(DecFile, NewDecFile); /*********** DECRYPT FUNCTION ************/
break;
}
return 0; //Exit!
}
//////////////////////////////////////////////////////////////////////////////////
// That's it! Looks so long yet it's so simple and easy to understand!
//////////////////////////////////////////////////////////////////////////////////
// So what we basicly done is open a file and add 25 to every byte of the file!
// Very simple!
//////////////////////////////////////////////////////////////////////////////////
// Any questions to chebby_shabby@hotmail.com
// If this tutorial is successful then my next tutorial is
// "A Beginner's Simple Compression Tutorial / Example
//////////////////////////////////////////////////////////////////////////////////
// by Adam Boulfoul
//////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
// This is not an "uncrackable" type of encryption but once you can understand the basics of
// this type of file encryption you CAN make better ones than me. This is just a quick example
// of basic encryption. Highly commented to help beginners.
/////////////////////////////////////////////////////////////////////////////////////////////////
// Before we start:
// What this basic program does is simply getting a byte from a file then adding 25 to it
// (ofcouse you can change it to whatever you like).
/////////////////////////////////////////////////////////////////////////////////////////////////
// If you have any questions, my e-mail is above
/////////////////////////////////////////////////////////////////////////////////////////////////
#include
#include
#include
// As mentioned abode, we simply add 25 to a byte, change this to whatever you like.
#define ENCRYPTION_FORMULA (int) Byte + 25
// The decryption formula is the opposite to encryption formula, every "+" is a "-"
#define DECRYPTION_FORMULA (int) Byte - 25
///////////////////////////////////////////////////////////////////////////////////////////
// TIP: Everytime you see ENCRYPTION_FORMULA ot DECRYPTION_FORMULA mensioned, highlight it
// then press on definition and it will bring you up here! (Only on Visual C++)
///////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// Our main function, put this in your program, FILENAME is the file to encrypt
// and NEW_FILENAME is the new location of the encrypted file
/////////////////////////////////////////////////////////////////////////////////
int Encrypt (char * FILENAME, char * NEW_FILENAME)
{
ifstream inFile; // This is the file that we're going to encrypt and read
ofstream outFile; // Once we encrypt the file, this is it's new location
char Byte; // This is the FILENAME's byte, we'll add 25 to this later
///////////////////////////////////////////////////////////////
// Before we continue:
// ios:: in - Used for reading a file
// ios::out - Used for writing a file
// ios::binary - Used for reading or writing binary files
///////////////////////////////////////////////////////////////
inFile.open(FILENAME, ios::in | ios::binary); // We read this file in binary mode
outFile.open(NEW_FILENAME, ios::out | ios::binary); // And we write the file in binary mode
// eof() stands for End Of File, so while we are still reading the file, continue
while(!inFile.eof())
{
// Remember we need to change a byte so we add 25 to it
char NewByte;
//////////////////////////////////////////////////
// NOTE: Only use the .put() and .get() in loops
// because it only reads 1 Byte at a time!
//////////////////////////////////////////////////
// Out old byte is recieved from the file
Byte = inFile.get();
// If the file that we are reading has an error, turn 0
if (inFile.fail())
return 0;
//Remember our Encryption Formula above?
//Our new byte is recieved from it, see above
NewByte = ENCRYPTION_FORMULA;
// This simple puts the new byte, into the new file!
outFile.put(NewByte);
}
// We have to be neat so we close both the file that we're reading
// and the file that we're writing
inFile.close(); // (File to read)
outFile.close(); // (File to write)
return 1; // Success!
}
///////////////////////////////////////////////////////////////////////////////
// What's the point of encrypting a file if you can't decrypt it?
// If you're wondering why this is not commented it's because I've already
// explained everything above, notice that everything is the same except for
// two lines!
///////////////////////////////////////////////////////////////////////////////
int Decrypt (char * FILENAME, char * NEW_FILENAME)
{
ifstream inFile;
ofstream outFile;
char Byte;
inFile.open(FILENAME, ios::in | ios::binary);
outFile.open(NEW_FILENAME, ios::out | ios::binary);
while(!inFile.eof())
{
char NewByte;
Byte = inFile.get();
if (inFile.fail())
return 0;
/////////////////////////////////////////////////////
NewByte = DECRYPTION_FORMULA; // New Line! We just change the ENCRYPTION_FORMULA
// to DECRYPTION_FORMULA, see above
/////////////////////////////////////////////////////
outFile.put(NewByte);
}
inFile.close();
outFile.close();
return 1;
}
///////////////////////////////////////////////////////////////////////
// WARNING: If you choose to decrypt a file that it already decrypted
// then the file would be encrypted!
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// To use the functions in your program (doesn't have to be a DOS program),
// copy the 2 functions above, this is just an example, in the example I'm
// encrypting
///////////////////////////////////////////////////////////////////////////////////
int main()
{
///////////////////////////////////////////////////////////////////
// The functions can be used in not only DOS programs
// Since this is an example, I'll show you how to use them
///////////////////////////////////////////////////////////////////
char EncFile[200]; // This is the string for the file to be encrypted
char NewEncFile[200]; // This is the new location of the encrypted file
char DecFile[200]; // This is the string for the file to be decrypted
char NewDecFile[200]; // This is the new location of the decrypted file
int Choice; //The user's choice variable (1 = Encrypt 2 = Decrypt)
// In case you didn't know, all these "cout" just display a message
// Cin tells the user to input something
cout << "NOTE: You must encrypt the file with the same file extension!"<
cout << "Enter 1 to Encrypt / 2 to Decrypt"<
cin >> Choice; // In this case, our input is the user's choice
switch(Choice)
{
case 1: // Did the user choose to encrypt a file?
cout << "Enter the current Filename: ";
cin >> EncFile; // The user's input for the current file to be encrypted
cout << "Enter the new Filename: ";
cin >> NewEncFile; //The user's input for the new location of the encrypted file
Encrypt(EncFile, NewEncFile); /*********** ENCRYPT FUNCTION ************/
break;
case 2: // Or did the user choose to decrypt a file?
cout << "Enter the current Filename: ";
cin >> DecFile; //Already explained but with the decrypted file this time!
cout << "Enter the new Filename: ";
cin >> NewDecFile;
Decrypt(DecFile, NewDecFile); /*********** DECRYPT FUNCTION ************/
break;
}
return 0; //Exit!
}
//////////////////////////////////////////////////////////////////////////////////
// That's it! Looks so long yet it's so simple and easy to understand!
//////////////////////////////////////////////////////////////////////////////////
// So what we basicly done is open a file and add 25 to every byte of the file!
// Very simple!
//////////////////////////////////////////////////////////////////////////////////
// Any questions to chebby_shabby@hotmail.com
// If this tutorial is successful then my next tutorial is
// "A Beginner's Simple Compression Tutorial / Example
//////////////////////////////////////////////////////////////////////////////////
// by Adam Boulfoul
//////////////////////////////////////////////////////////////////////////////////
Subscribe to:
Posts (Atom)