Notes by magnum

Displaying keyword search results 1 - 10
Created by magnum on January 06, 2013 20:15:00    Last update: April 05, 2013 09:59:12
nslookup : $ nslookup www.google.com Server: 127.0.0.1 ... dig : $ dig +noall +answer www.google.com www.google.... host $ host www.google.com www.google.com has addres... About the use of reverse DNS from webdnstools.com : Many things use reverse DNS. An example is anti-spam email software. Before delivering an email, it is common for anti-spam software to perform a reverse DNS lookup on the IP address of the source mail server. It then checks that the reverse DNS entry matches the SPF record provided by the name server of the source email domain. If it does not match, it may flag the email as spam.
Created by magnum on November 03, 2012 08:57:35    Last update: November 03, 2012 08:57:35
Code snippet to check user name and password in C in Linux #include <sys/types.h> #include <pwd.h> #inc...
Created by magnum on October 22, 2012 19:48:03    Last update: October 22, 2012 19:48:03
execl takes the full path name of the command and variable length of arguments terminated by NULL: execl("/bin/ls", "/bin/ls", "-r", "-t", "-l", NULL... where the second argument is argv[0] , but can be any string! execlp will try to find the command from $PATH , so full path to command is not needed: execl("ls", "ls", "-r", "-t", "-l", NULL); execv is the equivalent of execl , except that the arguments are passed in as a NULL terminated array: char *args[] = {"/bin/ls", "-r", "-t", "-l", NULL ... execvp is the equivalent of execvl , excep that the arguments are passed in as a NULL terminated array: char *args[] = {"ls", "-r", "-t", "-l", NULL }; ...
Created by magnum on September 11, 2012 12:38:00    Last update: September 11, 2012 12:38:00
From bind man page: SYNOPSIS #include <sys/types.h> ... The bind call assigns an address and a port to a socket. That's it. There's no mention of client or server, so it can be used on a client socket or a server socket. But it's necessary for a server socket, otherwise clients do not know how to contact the server. For a client socket, the call is optional. When a client connects to a server or sends a message for the first time, a dynamic port is assigned to the client if there's no port assigned to it. If a port is bind beforehand, there's no dynamic assignment. Test code: int print_sock_info(int sockfd) { struct so... Prints: Local addr: 0.0.0.0, port: 0 Local addr: 0.0.0....
Created by magnum on August 15, 2012 11:34:53    Last update: August 15, 2012 11:34:53
I was scared the first time I saw a bunch of random URL requests from Chrome on my proxy server. Was the copy of Chrome on my machine hacked? It turned out that there was a "deep" reason for the behavior. From Nico Weber : If you type in a single-word search query, chrome needs to send a DNS request to check if this might be a single-word host name: For example, "test" might be a search for "test" or a navigation to "http://test". If the query ends up being a host, chrome shows an infobar that asks "did you mean to go to 'test' instead". For perf reasons, the dns query needs to be asynchronous. Now some ISPs started showing ads for non-existent domain...
Created by magnum on January 30, 2012 18:13:52    Last update: January 30, 2012 18:13:52
There are two ways you cat get the name of a host from its ip address: getnameinfo and gethostbyaddr . The former is IPV6 compatible. Using getnameinfo : #include <sys/types.h> #include <sys/socket.h> ... Using gethostbyaddr : #include <sys/types.h> #include <sys/socket.h> ...
Created by magnum on September 24, 2011 13:14:37    Last update: September 28, 2011 18:08:35
There are two sides to an IP socket: the local side and the remote side: The getpeername function retrieves the peer address of the specified socket. #include <sys/socket.h> int getpeername(int soc... Example: struct sockaddr_in addr; socklen_t socklen = si... The getsockname function retrieves the locally-bound name of the specified socket. #include <sys/socket.h> int getsockname(int soc... Example: struct sockaddr_in addr; socklen_t socklen = si...
Created by magnum on September 27, 2011 21:51:05    Last update: September 28, 2011 18:02:49
Client socket usually does not call bind . But I've seen code that does and it was puzzling to me what bind does to a client socket. Therefore, this little test program. It retrieves a web url and displays info about the socket. You can optionally give a bind host name/ip and port and see what it does. Here are my test results: $ ./client www.google.com Local addr: 172.16.0.... This is the code: #include <stdio.h> #include <stdlib.h> #incl...
Created by magnum on September 28, 2011 09:31:58    Last update: September 28, 2011 09:31:58
This procedure works for xl2tpd . Edit L2TP configuration file /etc/xl2tpd/xl2tpd.conf : ; ; This is a minimal sample xl2tpd configurati... Edit PPP options file for L2TP /etc/ppp/options.xl2tpd.client : ipcp-accept-local ipcp-accept-remote refuse-... Edit PPP authentication file /etc/ppp/chap-secrets : # Secrets for authentication using CHAP # serve... Start xl2tpd : # /etc/init.d/xl2tpd start Connect to the server: # echo "c vpnserver" >/var/run/xl2tpd/l2tp-control Tail /var/log/messages , you should see something like: Sep 28 11:05:46 sta101894 pppd[26059]: pppd 2.4.5 ... ifconfig should show that ppp0 is added: # ifconfig ppp0 ppp0 Link encap:Point-to-P... To tear down the vpn: # echo "d vpnserver" >/var/run/xl2tpd/l2tp-control If authentication fails, try to set "require authentication" to no on both server and client and restart xl2tpd on both sides: # /etc/init.d/xl2tpd restart # echo "c vpnserve......
Created by magnum on September 23, 2011 16:06:02    Last update: September 28, 2011 09:29:53
This procedure works for xl2tpd . Edit L2TP configuration file /etc/xl2tpd/xl2tpd.conf : ; Sample l2tpd.conf ; [global] ; listen... Edit PPP options file for L2TP /etc/ppp/options.xl2tpd : ipcp-accept-local ipcp-accept-remote ms-dns ... Edit PPP authentication file /etc/ppp/chap-secrets : # Secrets for authentication using CHAP # serve... Start the server: # /etc/init.d/xl2tpd start Monitor the log: # less /var/log/messages
Previous  1 2 Next