Archive for the ‘Programming’ Category
I was working on a project for work on how to log host declarations in DHCP. In your /etc/dhcpd.conf file you may have something like:
host TestPC001 {
hardware ethernet d0:50:56:ac:74:71;
fixed-address 208.x.x.75;
}
For logging purposes if you wanted to see which host got what IP when, this will be a good way to do it. Assuming your dhcpd.conf file is generated dynamically via 3rd party software like NetReg for example. All you will need to do is add the following code in your DHCP file:
if known {
log (info, concat ("HOSTNAME: ", host-decl-name, " on ",binary-to-ascii (10, 8, ".", leased-address)," at ", binary-to-ascii (16, 8, ":", substring (hardware, 1, 6))));
}
It will log to the DHCP Log file as information for hostname by using their host declaration, their lease address and finally their hardware ethernet address.
The log file before the change (timestamps removed):
DHCPDISCOVER from d0:50:56:ac:74:71 via eth0
DHCPOFFER on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
DHCPREQUEST for 208.x.x.75 (172.18.1.2) from d0:50:56:ac:74:71 via eth0
DHCPACK on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
The log file after adding the function:
HOSTNAME: TestPC001 on 208.x.x.75 at d0:50:56:ac:74:71
DHCPDISCOVER from d0:50:56:ac:74:71 via eth0
DHCPOFFER on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
DHCPREQUEST for 208.x.x.75 (172.18.1.2) from d0:50:56:ac:74:71 via eth0
DHCPACK on 208.x.x.75 to d0:50:56:ac:74:71 via eth0
Tags: DHCP, Logging
I recently got a Samsung Omnia phone and I love this thing. Then I decided to play around with .NET programming for windows mobile and decided to write a small alarm app using the accelerometer. The problem was, there was hardly any code about using the accelerometer. That is until I stumbled upon the SDK for Samsung Mobile Phones. The one catch was, it is written in C++, with DLL wrappers written in C#, no VB. So I took the C# wrapper code and converted it over to VB.NET and included it in my application.
shared.vb
acceleromoter.vb
In order to use these files, you will need to download the Samsung Mobile SDK from http://innovator.samsungmobile.com/
Here is an example on how to use the code:
Dim AccVec As New SamsungMobileSdk.Accelerometer.Vector()
Dim Accelerometer As New SamsungMobileSdk.Accelerometer
If Accelerometer.GetVector(AccVec) = SamsungMobileSdk.SmiResultCode.Success Then
Dim x,y,z as integer
x = AccVec.x
y = AccVec.y
z = AccVec.z
end if
Tags: .NET, Mobile, Omnia, Samsung, SDK, VB.NET
Well, last hour or so has been interesting. I was going to my website I was working on http://gadsdenwifi.org and my antivirus popped up a notice saying it deleted a temporary internet file. I shrugged it off (as I had other tabs open and thought it was one of others. After a bit I noticed that my computer was starting to run slow and sluggish. Thats when I noticed acrobat.exe using 800 megs of ram and slowly climbing. Also thats when I noticed sysguard.exe in my process list. No surprise to me some anti spyware program popped up and started running on my computer (spyware protect 2009). Running combo fix took care of that problem. So after fixing the spyware issue, I started playing around with the newly uploaded database information. I then decided to change the test site around just a bit. I uploaded index.php and got a message saying that the file on the server was newer than the last uploaded one, so I went to check it out. Thats when I found this nice little bugger:

Some reason, every index.php file on my webserver had this code enbedded around a few php eco statements, which caused my antivirus to pop up warning me that there was a trojan trying to infest my computer. All infected files have been removed and everything should be normal (I hope).
We shall see in the next couple of days.
Tags: acrobat, combo fix, exploit, Gadsden, javascript, malicious, security, spyware protect 2009, Wifi
Here is a quick update on the Gadsden Wifi project.
- Aquired Gadsdenwifi.org (thanks http://www.brandonrome.net for the logo)
- The database structure is complete and the import software is 70% complete.
- The backend programming will begin after the database is complete.
Few things I have learned:
- Binary Searching
- Minimizing database calls (atleast on SELECT statements)
- Basics of Multi-Threading applications.
- Basics of Google Maps API
Tags: .NET, database, Gadsden, Projects, Wifi
For an update, I have posted a screenshot of the program I wrote (few hours of sitting down and punching the good ol’ keyboard). The program takes a Wifi Scan text document and converts it into a Google Earth KML file. If you click the image below, you can see the full screen shot of what my program looks like, the tree structure listed in google earth and the information that pops up when you click on said point.
By doing this little project, i’ve learned about writing XML documents and how easy it can be and how big of a pain it could be. Also this project stresses the way I used to code. For example, a 750 KB file with 6,000 data points works flawlessly. Toss in a 10 meg file with 54,000 data points and you will see real quick that handling data is alot different.
Things I’ve Learned:
- Redim Preserve statement is a bad bad bad idea if called once per loop. It basically creates an array thats bigger (or smaller), copies the old array to the new array (2x memeory consumption), then destroys the old array.
- Better to Add items all at once vs one at a time on List View Boxes (still learning to program this one).
- Google Earth is picky when it comes to <document> and <Document> …
This program for the most part is complete, once I fine tune it and get everything running smoothly, I will see about the website side of this project.

Tags: Gadsden, Google Earth, Programming, Projects, Wifi
This is my first attempt at a custom function library. I find myself using some of the same functions through out my apps that I just decided to put it in just one small package.
Here is the networking side of it:
IsIP(IPAddress as String)
IPAddress: A String with an IP address in it.
Returns: True or False
IsSubnet(SubnetMask as String)
SubnetMask: Takes a string with a valid SubnetMask or CIDR Notation.
Returns: True or False
CIDRtoSubnet(CIDRNotation as String)
CIDRNotation: A string with a valid CIDR notation.
Returns: Returns a SubnetMask, or false if invalid.
GetIPRanges(NetworkAddress as String)
NetworkAddress: Takes a string with a valid IP address and SubnetMask.
Returns: An array with the beginning and ending IP address range. Returns false if its invalid.
IsInIPRange(IPAddress as String, SubnetMask as String, IPtoCheck as String)
IPAddress: String with a valid IP address.
SubnetMask: String with a valid IP address.
IPtoCheck: String of the IP address to check.
Returns: True or False
IPIncrement(IPAddress as String, Increment as Double, Optional SubnetMask as String)
IPAddress: A String with a valid IP address.
Increment: A positive numeric value to increase the IP address.
SubnetMask (optional): To check if the incremented IP address is in a valid network range.
Returns: Returns a valid IP address. (Returns False if SubnetMask is used and the IP address is out of range.)
Tags: Functions, Jinan, Library, Networking, VB.NET
I have been working on a anti-spam filter for comments to use on my website arthurwinters.net. This filter takes as string of text, analyzes it and returns either a 0 (not spam) or a 1 (spam). The spam filter is based on a scoring system which judges the following:
- Word Count and Character Count.
- How many URLs are in the post.
- How many bad domain keywords, and path keywords in the post.
- How many bad keywords are in the post.
- How many constant characters are in a row.
Depending on the situation it could be given a positive score or a negative score. This combined with an overall score will give the post a percentage, based on that percentage and a threshold determined, it is then marked as spam or not spam.
Feel free to try it out at http://www.arthurwinters.net/beta
Tags: Filter, PHP, Spam
Download: XLS to CSV Converter
Size: 7.5 kB
This program will convert any non password protected excel document into a comma seperated value file. You can supply options to run it externally from another script or use the interactive menu by supplying the -m option.
Disclaimer: I am not responsible for what this may do to you, your computer, car, home, life, cat, dog, mother, father, etc. Use this at your own risk.
Screenshot
Tags: Apps, Programming, XLS to CSV
That is all.
Tags: Jinanrealm