|
Thanks dnh! it's the same that I was thinking!
Have a nice week!.
SINCERELY.
ANTHONY ACUÑA
PREFERED PHRASE:
SOMEBODY TELL ME WHY IS MORE REAL WHEN I DREAM THAT I AM WAKE?
|
|
|
|
|
I am new to C# programming and I am very much interested to develop a firewall which could defy IP SPOOFING. I have not knowledged myself in Network Programming but I intend to develop a firewall though. " My message to all the Coders visiting this site is that - Please give me valuable tips in developing a firewall and some codes to shut an IP which produces avalanche effect on the system. This helps the firewall to have a offensive mode rather than a defensive mode . " I would obliged if I were helped by any coder.
love coders'
|
|
|
|
|
MACODER wrote: Please give me valuable tips in developing a firewall and some codes to shut an IP
Look at developing an NDIS driver. You cannot do that in C#. Although, interestingly, you can develop the basics of the driver and pass information through to a C# service. However, since the driver sits in the kernal and the C# application in the user space it produces many inefficiences. I know, I've tried.
MACODER wrote: I have not knowledged myself in Network Programming
Then I suggest that you read up on the subject before taking on such a task.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
A firewall really isn't an appropriate place to put up a defense such as this. An attack like that will knock you off the wire if it gets inside your router. The network card that your firewall is running on will still get inundated with traffic, even though you'll be discarding most of it. The trickle of good traffic will still not be able to get through the ocean of bad.
Borders routers, at the ISP or your corporate network, are the best place to put up filters such as these. You also won't be filtering just one address either, you'll be filtering out hundreds of addresses, and even ports, at a time.
If you want a couple of samples of what a modern-day attack is like, then check out the write-ups from Steve Gibson[^] and what his site got knocked down with.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 11:11 Wednesday 18th January, 2006
|
|
|
|
|
Hi, I'm trying to find out how to create a password protected transparent screen lock using C#. Generally, it should be able to do the following when "locked":
1. disable key combinations like ctrl+alt+del, alt+tab, etc.
2. disable the mouse and hide the cursor.
Thank you.
sw
|
|
|
|
|
I'm kinda new to C#. I'm trying to make a program with a TreeView. My program creates 2 nodes when the program loads and all data appears as children to those two nodes. I also have a context menu that is set to change depending on the type of selection made.
The first issue is when the program starts, the first node is selected and it's context menu comes up automatically. How can I stop that? I tried to see if I could make an exception but nothing worked out.
The second is when I use the ContextMenu Show() function, I give it an ordered pair location to anchor the top-left corner. I tried to use various things inside the control to give a position of the mouse but the context menu always appears at 8,8 from the corner of the tree view. How can I figure out what coordinates the mouse was at when it clicked on the item?
Thanks in advance.
|
|
|
|
|
what is the difference b/w Control and Literal?
Also what is a literal control?
THanks
|
|
|
|
|
Is this ASP.NET ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Control is the base class for all web controls. A Literal is a control that will just render as the text that you put in the Text property.
<asp:Literal Runat="server" Text="asdf" />
will simply render as:
asdf
---
b { font-weight: normal; }
|
|
|
|
|
How do I set a window be topmost to only one window handle instead of all windows. Tried using SetWindowPos the hwndInserAfter does not work properly. Any help will be appreciated.
|
|
|
|
|
Make the window that you want your window to be on top of the parent of that window. So if Form1 creates Form2 and sets the Form1 instance to be the parent of the Form2 instance, it will always be above the Form1 instance, as you'd expect from a child dialog.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I just tried win32 setparent method it works. Can someone validate if this is ok.
|
|
|
|
|
Your Form has a Parent property, you don't need to do anything with Win32.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The child window is on a separate background thread. If I set the parent property I am getting some exception like "Cannot add top level control". The win32 functions works perfectly. I need this window on the background thread to overlap the main ui thread window. Thereby I can have modal windows which will not block the main thread. We have some legacy applications which are being auto generated into C# code. These apps have lots of modal windows. We have to plug in these apps into a UI framework already deployed. These individual apps will reside on different tabs in the UI framework. When these apps open modal windows we need to be able to other tabs. Hope this explains why we have to run this in a separate thread with its own message loop. Each interaction with the main UI thread will be synchronized via BeginInvoke. There will be minimal interaction with UI thread controls except for getting some static security tokens, cust name etc.
-- modified at 1:11 Wednesday 18th January, 2006
|
|
|
|
|
Careth Jefferson wrote: "Cannot add top level control".
That's a new error - you can use an attribute to get rid of that.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
[DllImport("user32.dll")]
public static extern bool BringWindowToTop(IntPtr hWnd);
public void BringToTop()
{
BringWindowToTop(this.Handle);
}
|
|
|
|
|
Hi Guys:
i would like to know how to do the owner draw for hscrollbar c# 2005?
anyone?
|
|
|
|
|
There's not an OwnerDraw property ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
TripleDES in outer cipher block chaining mode (CBC) without having the needed IV (Initialization Vector) ?
I am trying to write a client program for a server using a strange protocol that isn’t very well documented. I am completely lost here and I don’t know how to do this. Hope someone can enlighten me and help me out here.
The protocol says that I have to encrypt the tcp packages sent from the client to the server using TripleDES in outer cipher block chaining mode with a 14 byte DES key. (The key is known on the server and on the client)
Correct me if I am wrong here. But don’t you need two keys to encrypt a message using TripleDES CBC ? One key and one IV (Initialization Vector).
The documentation doesn’t tell me anything about what IV key the servers uses to decrypt the messages once it is received on the server side so I don’t know what IV key to encrypt the messages with. I know this is VERY vague, but I don’t know how to explain it any better.
Hope anyone can help me out here.
|
|
|
|
|
The initialisation vector (IV) is not a key. It is a sequence of random digits that are applied to the start of the encrypted document. This is because for certain documents there is a well known starting sequence and given the same key, they would all encrypt to the same value, so the first few bytes of the encrypted text of multiple documents using the same key would look the same. Crack one and you have the others. The IV scrambles the start of the document and becuase the encryption of block n+1 depends on how block n was encrypted it becomes exceedingly difficult to determine any repeated sections of the file.
The IV is known and you are free to transmit it in plaintext because even if an attacker gets hold of it they cannot do anything with it without the key. The IV should be different on each communication otherwise similar files will look similar when encrypted.
I don't know if this helps with your problem, but knowing a bit more about the IV may help you track down a solution more easily.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Thanks, this helped me.
I think my problem is that the protocol isnt very well documented becuase it doesnt say anything on how to generate the iv and how i should tell the server witch IV i used to decrypt the message.
If i encrypt a message with these keys on the client side:
DES KEY: byte[] localDesKey = {01,02,03,04,05,06,07,08,09,10,11,12,13,14};
Randomly generated IV : byte[] myIV = {02,02,03,12};
The server allready know the DES key but would also need the IV to decrypt the message. Am I right ?
The protocol documentation doesnt say anything about how I should tell the server what IV i used.
This is what the protocol documentation is telling me .
<protocol.txt>
Uses encrypted tcp connections to communicate with its cardservers,
for every card a dedicated tcp connection is used.The encryption used is
Triple-DES in outer cipher block chaining mode (CBC)
After opening a TCP connection to the server, the client first receives 14
random bytes. These bytes are to be XORed to the Triple-DES key from the config
file. (.). The result forms the
Triple DES key to be used to send Username and Password to the server, I
call it the login key.
Next the client has to send a packet with cmd = MSG_CLIENT_2_SERVER_LOGIN
including username and password in the data field.
The username is sent as a C-String (NULL terminated), the password
follows directly after the zero termination byte of the username. The
password has to be put through the glibc crypt() function, using salt
$1$abcdefgh$. The password in the data field has to be NULL terminated and the
packet encrypted with the login key.
|
|
|
|
|
jbergetun wrote: The server allready know the DES key but would also need the IV to decrypt the message. Am I right ?
Right. The client and server are both using the same key, but the client generates the IV when it communicates with the server (and vice versa) so it needs some way of communicating the IV to the server.
jbergetun wrote: After opening a TCP connection to the server, the client first receives 14
random bytes.
the random bytes are the IV I'd guess*, there is no other reason for starting the communication with 14 random bytes. The IV is typically XORed into the start of the data stream rather than the key - I'm not sure what the effect would be, it is randomising the key so that the encrypted version of the user name and password being sent is at least different each time it is sent.
* "guess" being the operative word
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I found some source code for a client programmed in C.
Dont understand much but maybe someone else does.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <rpc des_crypt.h="">
#include <sys socket.h="">
#include <netinet in.h="">
#include <netdb.h>
#define CWS_NETMSGSIZE 240
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define CWS_FIRSTCMDNO 0xe0
typedef enum
{
MSG_CLIENT_2_SERVER_LOGIN = CWS_FIRSTCMDNO,
MSG_CLIENT_2_SERVER_LOGIN_ACK,
MSG_CLIENT_2_SERVER_LOGIN_NAK,
MSG_CARD_DATA_REQ,
MSG_CARD_DATA,
MSG_SERVER_2_CLIENT_NAME,
MSG_SERVER_2_CLIENT_NAME_ACK,
MSG_SERVER_2_CLIENT_NAME_NAK,
MSG_SERVER_2_CLIENT_LOGIN,
MSG_SERVER_2_CLIENT_LOGIN_ACK,
MSG_SERVER_2_CLIENT_LOGIN_NAK,
MSG_ADMIN,
MSG_ADMIN_ACK,
MSG_ADMIN_LOGIN,
MSG_ADMIN_LOGIN_ACK,
MSG_ADMIN_LOGIN_NAK,
MSG_ADMIN_COMMAND,
MSG_ADMIN_COMMAND_ACK,
MSG_ADMIN_COMMAND_NAK,
MSG_KEEPALIVE = CWS_FIRSTCMDNO + 0x1d
} net_msg_type_t;
typedef enum
{
COMMTYPE_CLIENT,
COMMTYPE_SERVER
} comm_type_t;
typedef struct customData_struct
{
uint16 sid;
} customData_t;
void des_key_parity_adjust(uint8 *key, uint8 len)
{
uint8 i, j, parity;
for (i = 0; i < len; i++)
{
parity = 1;
for (j = 1; j < 8; j++) if ((key[i] >> j) & 0x1) parity = ~parity & 0x01;
key[i] |= parity;
}
}
uint8 *des_key_spread(uint8 *normal)
{
static uint8 spread[16];
spread[ 0] = normal[ 0] & 0xfe;
spread[ 1] = ((normal[ 0] << 7) | (normal[ 1] >> 1)) & 0xfe;
spread[ 2] = ((normal[ 1] << 6) | (normal[ 2] >> 2)) & 0xfe;
spread[ 3] = ((normal[ 2] << 5) | (normal[ 3] >> 3)) & 0xfe;
spread[ 4] = ((normal[ 3] << 4) | (normal[ 4] >> 4)) & 0xfe;
spread[ 5] = ((normal[ 4] << 3) | (normal[ 5] >> 5)) & 0xfe;
spread[ 6] = ((normal[ 5] << 2) | (normal[ 6] >> 6)) & 0xfe;
spread[ 7] = normal[ 6] << 1;
spread[ 8] = normal[ 7] & 0xfe;
spread[ 9] = ((normal[ 7] << 7) | (normal[ 8] >> 1)) & 0xfe;
spread[10] = ((normal[ 8] << 6) | (normal[ 9] >> 2)) & 0xfe;
spread[11] = ((normal[ 9] << 5) | (normal[10] >> 3)) & 0xfe;
spread[12] = ((normal[10] << 4) | (normal[11] >> 4)) & 0xfe;
spread[13] = ((normal[11] << 3) | (normal[12] >> 5)) & 0xfe;
spread[14] = ((normal[12] << 2) | (normal[13] >> 6)) & 0xfe;
spread[15] = normal[13] << 1;
des_key_parity_adjust(spread, 16);
return spread;
}
void des_random_get(uint8 *buffer, uint8 len)
{
uint8 idx = 0;
int randomNo = 0;
for (idx = 0; idx < len; idx++)
{
if (!(idx % 3)) randomNo = rand();
buffer[idx] = (randomNo >> ((idx % 3) << 3)) & 0xff;
}
}
int des_encrypt(uint8 *buffer, int len, uint8 *deskey)
{
uint8 checksum = 0;
uint8 noPadBytes;
uint8 padBytes[7];
char ivec[8];
uint16 i;
if (!deskey) return len;
noPadBytes = (8 - ((len - 1) % 8)) % 8;
if (len + noPadBytes + 1 >= CWS_NETMSGSIZE-8) return -1;
des_random_get(padBytes, noPadBytes);
for (i = 0; i < noPadBytes; i++) buffer[len++] = padBytes[i];
for (i = 2; i < len; i++) checksum ^= buffer[i];
buffer[len++] = checksum;
des_random_get((uint8 *)ivec, 8);
memcpy(buffer+len, ivec, 8);
for (i = 2; i < len; i += 8)
{
cbc_crypt(deskey , (char *) buffer+i, 8, DES_ENCRYPT, ivec);
ecb_crypt(deskey+8, (char *) buffer+i, 8, DES_DECRYPT);
ecb_crypt(deskey , (char *) buffer+i, 8, DES_ENCRYPT);
memcpy(ivec, buffer+i, 8);
}
len += 8;
return len;
}
int des_decrypt(uint8 *buffer, int len, uint8 *deskey)
{
char ivec[8];
char nextIvec[8];
int i;
uint8 checksum = 0;
if (!deskey) return len;
if ((len-2) % 8 || (len-2) < 16) return -1;
len -= 8;
memcpy(nextIvec, buffer+len, 8);
for (i = 2; i < len; i += 8)
{
memcpy(ivec, nextIvec, 8);
memcpy(nextIvec, buffer+i, 8);
ecb_crypt(deskey , (char *) buffer+i, 8, DES_DECRYPT);
ecb_crypt(deskey+8, (char *) buffer+i, 8, DES_ENCRYPT);
cbc_crypt(deskey , (char *) buffer+i, 8, DES_DECRYPT, ivec);
}
for (i = 2; i < len; i++) checksum ^= buffer[i];
if (checksum) return -1;
return len;
}
uint8 *des_login_key_get(uint8 *key1, uint8 *key2)
{
uint8 des14[14];
static uint8 des16[16];
int i;
for (i = 0; i < 14; i++)
{
des14[i] = key1[i] ^ key2[i];
}
memcpy(des16, des_key_spread(des14), 16);
return des16;
}
int network_message_send(int handle, uint16 *netMsgId, customData_t *customData, uint8 *buffer, int len, uint8 *deskey, comm_type_t commType)
{
uint8 netbuf[CWS_NETMSGSIZE];
if (len < 3 || len + 12 > CWS_NETMSGSIZE || handle < 0) return -1;
buffer[1] = (buffer[1] & 0xf0) | (((len - 3) >> 8) & 0x0f);
buffer[2] = (len - 3) & 0xff;
memcpy(netbuf+12, buffer, len);
len += 12;
if (netMsgId) { if (commType == COMMTYPE_CLIENT) (*netMsgId)++; netbuf[2] = (*netMsgId) >> 8; netbuf[3] = (*netMsgId) & 0xff; }
else netbuf[2] = netbuf[3] = 0;
if (customData)
{
netbuf[4] = customData->sid >> 8;
netbuf[5] = customData->sid & 0xff;
memset(netbuf+6, 0, 6);
}
else memset(netbuf+4, 0, 8);
if ((len = des_encrypt(netbuf, len, deskey)) < 0) return -1;
netbuf[0] = (len - 2) >> 8;
netbuf[1] = (len - 2) & 0xff;
write(handle, netbuf, len);
return 0;
}
int network_message_receive(int handle, uint16 *netMsgId, customData_t *customData, uint8 *buffer, uint8 *deskey, comm_type_t commType)
{
int len;
uint8 netbuf[CWS_NETMSGSIZE];
int returnLen;
if (customData) memset(customData, 0, sizeof(customData_t));
if (!buffer || handle < 0) return -1;
len = read(handle, netbuf, 2);
if (!len) return 0;
if (len != 2) return -1;
if (((netbuf[0] << 8) | netbuf[1]) > CWS_NETMSGSIZE - 2) return -1;
len = read(handle, netbuf+2, (netbuf[0] << 8) | netbuf[1]);
if (!len) return 0;
if (len != ((netbuf[0] << 8) | netbuf[1])) return -1;
len += 2;
if ((len = des_decrypt(netbuf, len, deskey)) < 15) return -1;
if ((returnLen = (((netbuf[13] & 0x0f) << 8) | netbuf[14]) + 3) > len-12) return -1;
if (netMsgId)
{
switch (commType)
{
case COMMTYPE_SERVER:
*netMsgId = (netbuf[2] << 8) | netbuf[3];
break;
case COMMTYPE_CLIENT:
if (*netMsgId != ((netbuf[2] << 8) | netbuf[3])) return -1;
break;
default:
return -1;
break;
}
}
if (customData)
{
customData->sid = (netbuf[4] << 8) | netbuf[5];
}
memcpy(buffer, netbuf+12, returnLen);
return returnLen;
}
void network_cmd_no_data_send(int handle, uint16 *netMsgId, customData_t *customData, net_msg_type_t cmd, uint8 *deskey, comm_type_t commType)
{
uint8 buffer[CWS_NETMSGSIZE];
buffer[0] = cmd; buffer[1] = 0;
network_message_send(handle, netMsgId, customData, buffer, 3, deskey, commType);
}
int network_cmd_no_data_receive(int handle, uint16 *netMsgId, customData_t *customData, uint8 *deskey, comm_type_t commType)
{
uint8 buffer[CWS_NETMSGSIZE];
if (network_message_receive(handle, netMsgId, customData, buffer, deskey, commType) != 3) return -1;
return buffer[0];
}
int network_tcp_incoming_port_open(uint16 port)
{
struct sockaddr_in socketAddr;
int socketOptActive = 1;
int handle;
if (!port) return -1;
if ((handle = socket(PF_INET, SOCK_STREAM, 0)) < 0)
{
fprintf(stderr, "network port %u open: ", port);
perror("socket");
return -1;
}
if (setsockopt(handle, SOL_SOCKET, SO_REUSEADDR, &socketOptActive, sizeof(int)) < 0)
{
fprintf(stderr, "network port %u open: error setsockopt\n", port);
close(handle);
return -1;
}
socketAddr.sin_family = AF_INET;
socketAddr.sin_port = htons(port);
socketAddr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(handle, (struct sockaddr *) &socketAddr, sizeof (socketAddr)) < 0)
{
fprintf(stderr, "network port %u open: ", port);
perror("bind");
close(handle);
return -1;
}
if (listen(handle, 5) < 0)
{
fprintf(stderr, "network port %u open: ", port);
perror("listen");
close(handle);
return -1;
}
return handle;
}
int network_tcp_connection_accept(int socketHandle)
{
int connHandle;
struct sockaddr_in peerAddr;
struct sockaddr_in myAddr;
socklen_t peerAddrLen;
socklen_t myAddrLen;
uint16 peerPort, myPort;
uint32 peerIp, myIp;
if (socketHandle < 0) return -1;
peerAddrLen = sizeof(peerAddr);
myAddrLen = sizeof(myAddr);
if ((connHandle = accept(socketHandle, (struct sockaddr *) &peerAddr, &peerAddrLen)) < 0) { fprintf(stderr, "error network accept connection\n"); return -1; }
peerPort = ntohs(peerAddr.sin_port);
peerIp = ntohl(peerAddr.sin_addr.s_addr);
myPort = ntohs(myAddr.sin_port);
myIp = ntohl(myAddr.sin_addr.s_addr);
/* optional: do checks on or log IP of incoming connections */
return connHandle;
}
int network_tcp_connection_open(uint8 *hostname, uint16 port)
{
int handle;
struct hostent *hostaddr;
struct sockaddr_in socketAddr;
if (!(hostaddr = gethostbyname(hostname))) { fprintf(stderr, "Host lookup of %s failed\n", hostname); return -1; }
if ((handle = socket(PF_INET, SOCK_STREAM, 0)) < 0) { fprintf(stderr, "network make connection: couldn't create socket\n"); return -1; }
socketAddr.sin_family = AF_INET;
socketAddr.sin_port = htons(port);
socketAddr.sin_addr.s_addr = ((struct in_addr *)hostaddr->h_addr)->s_addr;
if (connect(handle, (struct sockaddr *)&socketAddr, sizeof(socketAddr)) < 0) { fprintf(stderr, "network make connection: error connect\n"); close(handle); return -1; }
return handle;
}
|
|
|
|
|
Hi,
I am working on a project with a WebBrowser, the poblem is I am looping in a function, and then I want the function to wait until the Document finishes loading..
something like this is what I am doing,
HTMLSelectElementClass sEC2 = (HTMLSelectElementClass) myDoc.all.item( "sel", 0 );
for( int x=0; x
|
|
|
|
|
i nead a code that calculating fraction by using operatoroverloading and the LCM and GCD
|
|
|
|
|