As a Security/Systems Administrator, one of my task is to scan for rouge devices, services and other status and/or information regarding our network. One of the major task is to know which hosts belongs to a specified IP Range for example 192.168.0.1 to 192.168.100.255.
One of the best solutions and probably the fastest is to convert the Ip range and iterate in its Binary form. With the help of shift operators (<< and >>), & and | operator here is my simple implementation in C# =)
-----------------------------------------------------------------
int counter;
int[] ipStart = {192,168,0,0};
int[] ipEnd = {192,168,255,255};
int startIP= (
ipStart[0] << 24 |
ipStart[1] << 16 |
ipStart[2] << 8 |
ipStart[3]);
int endIP= (
ipEnd[0] << 24 |
ipEnd[1] << 16 |
ipEnd[2] << 8 |
ipEnd[3]);
for (counter = startIP; counter <= endIP; counter++)
{
Console.WriteLine("{0}.{1}.{2}.{3}",
(counter & 0xFF000000) >> 24,
(counter & 0x00FF0000) >> 16,
(counter & 0x0000FF00) >> 8,
counter & 0x000000FF);
}
-------------------------------------------------------------------------
0xFF000000 is equal to 11111111000000000000000000000000 in Binary
0x00FF0000 is equal to 00000000111111110000000000000000 in Binary
0x0000FF00 is equal to 00000000000000001111111100000000 in Binary
0x000000FF is equal to 00000000000000000000000011111111 in Binary
Till Next Time.......
I was trying to deploy a project in our new web server when I encountered this
error HTTP Error 500.19 - Internal Server Error "The requested page cannot be accessed because the related configuration data for the page is invalid"

Further investigation lead me to the captcha control I used from http://www.codeproject.com/KB/custom-controls/CaptchaControl.aspx. It seems like that my Http Handler config entry is not in ISS 7.0's Format. Tweaking and looking for solutions I found this procedures.
1. Open IIS 7.0 Management Console and open Handler Mapping

2. Under the Handler Mappings Page, Click on the "Add Managed Handler" Link (Found on the Upper Right corner of the screen)

3. Encode your httphandler properties, which on my case is seen below and click OK,

Try to open your page =).... Hope this helps....
I just installed my PC with Windows 7 64bit, Microsoft Office 2007 and Visual Studio 2010. I was trying something and I have decided to use Microsoft Access as my database, After a few minutes I found my self scratching my head because I cannot Connect My App to my MS Access Database because of thess errors
"The setup routines for the Microsoft Access Driver(*.mdb, *.accdb) ODBC driver could not be found. Please reinstall the driver"
Errors Found: The specified DSN contains an architecture mismatch between the Driver and Application
Here are some screen shots


After googling around I found this 2007 Office System Driver: Data Connectivity Components Just Download and install it.
and I also found this Windows 7 RC ODBC Access driver, So this lead me to C:\Windows\SysWow64. So what I did was to create a DSN File named MyAccessDatabase.dsn using the odbcad32.exe found inside C:\Windows\SysWow64 instead of the Data Sources (ODBC) Applet found under the Administrative Tools Control Panel Folder
Here's the resulting DNS File
[ODBC]
DRIVER=Microsoft Access Driver (*.mdb, *.accdb)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
PageTimeout=5
MaxScanRows=8
MaxBufferSize=2048
FIL=MS Access
DriverId=25
DefaultDir=c:\Data
DBQ=C:\Data\database.accdb
So this Works Perfectly now 
OdbcConnection cnn = new OdbcConnection();
cnn.ConnectionString = @"filedsn=C:\Data\MyAccessDatabase.dsn;
Uid=admin;Pwd=password;";
try
{
cnn.Open();
MessageBox.Show(cnn.State.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
cnn.Close();
}
But if you dont use a File DSN this should Work Fine......
OleDbConnection cnn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=c:\database.accdb;Jet OLEDB:Database Password=password;");
cnn.open();
I Updated my Rig and after several days I noticed that some randomly named folder was created on my mobile drive.

I tried to delete the folder but an error message popped out saying that I don't have any permission on the folder, WTH!!! I am the admin of my computer.

I tried to take ownership of the folder by checking the security Properties of the folder. After retrying, Major Fail. Then I heard from a friend about this registry tweak that will add "Take Ownership" on your right click menu.
NOTE: You can also Download the attached file instead of following the instructions below. Just double click on the REG Files
Installation
1. Open Notepad
2. Paste the following code
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
3. Save the file as Install.Reg
4. Double click Install.Reg

UnInstallation
1. Open Notepad
2. Paste the following code
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\*\shell\runas]
[-HKEY_CLASSES_ROOT\Directory\shell\runas]
3. Save the file as Install.Reg
4. Double click Install.Reg
After taking ownership of the folder using my new "Take Ownership" Menu. and trying to delete the Damn Folder =) Successs......
Note: Tested Under Windows 7
We encountered a problem on our email server and as an initial procedure I tried to read the logs, the log says that
relay=none, delay=141015, status=deferred (Name service error for yahoo.com: Host not found, try again)
so as an initial response i tried to check on /etc/resolve.conf, ping, dig and nslookup, but the problem is results are all ok, further looking for resources through google lead me to /var/spool/postfix/etc/resolve.conf so after changing my nameserver entries to a different DNS Server, Problems are now Ok.....
I am encountering this error on a freshly installed Named Instance SQL Server 2005
"Failed to retrieve data for this request.
(Microsoft.SqlServer.SmoEnum)
The
SQL Server specified in Integration Services service configuration is
not present or is not available. This might occur when there is no
default instance of SQL Server on the computer. For more information,
see the topic "Configuring the Integration Services Service" in SQL
Server 2008 Books Online.
Login Timeout Expired
An
error has occurred while establishing a connection to the server. When
connecting to SQL Server 2008, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote
connections.
Named Pipes Provider: Could not open a
connection to SQL Server [2]. (MsDtsSvr)."
after googling I found this blog post from http://www.igregor.net
http://www.igregor.net/post/2009/01/21/Connect-to-SSIS-on-Named-Instance-of-SQL-Server.aspx
Works like a charm =)
I currently have a new project and as an additional security I want to get the workstations MAC address and store it in the Log..
Here's my solution which I based somewhere.....
IPGlobalProperties NetworkProperties = IPGlobalProperties.GetIPGlobalProperties();
NetworkInterface[] NetworkInterfaceCards= NetworkInterface.GetAllNetworkInterfaces();
string macAddress = "";
VeteransBankENT.ApplicationVariables.CurrentHostName = NetworkProperties.HostName;
VeteransBankENT.ApplicationVariables.CurrentHostName = NetworkProperties.DomainName;
if (NetworkInterfaceCards == null || NetworkInterfaceCards.Length < 1)
{
MessageBox.Show(" No network interfaces found.");
}
foreach (NetworkInterface adapter in NetworkInterfaceCards)
{
if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet && adapter.OperationalStatus == OperationalStatus.Up)
{
IPInterfaceProperties properties = adapter.GetIPProperties(); // .GetIPInterfaceProperties();
PhysicalAddress address = adapter.GetPhysicalAddress();
byte[] bytes = address.GetAddressBytes();
for (int i = 0; i < bytes.Length; i++)
{
macAddress += bytes
.ToString("X2");
if (i != bytes.Length - 1)
{
macAddress += "-";
}
}
VeteransBankENT.ApplicationVariables.CurrentHost = macAddress;
break;
}
}
I was trying to upgrade one of my Test Web Applications to use Ajax, After going through the usual procedures of adding a ScriptManager and a UpdatePanel and adding some codes, I tried running my app for the first Time, I found out that my pages are still loading as a whole.
When I tried to check my Web.Config, I found out that my Web.Config lacks the entries related to Ajax. So what I did was I added the Ajax related Web.Config manually and violla my pages now runs perfectly.....
I don't know if this was a bug or I did something which caused my VS not to update my Web.Config.....Any comments guys?
I've been playing aroung with Jquery for months now but its only recently that I have tested jquery intellisense functionality in Visual Studio 2008
What I have noticed is, Intellisense works perfectly but not until referensing other Jquery Plugins like ui.datepicker.js. the warning message is
Warning 2 Error updating JScript IntelliSense: C:\Users\XXX\Desktop\JqueryExer\Scripts\jquery-1.3.2-vsdoc.js: 'div.childNodes' is null or not an object @ 1487:4 C:\Users\XXX\Desktop\JqueryExer\Pages\MasterPage.master 1 1 C:\...\JqueryExer1\
After surfing around I found a solution which is adding an empty file named ui.datepicker-vsdoc.js, so does this mean that for every plugin I have to add a -VSDOC version of that file? sadly as of writing its the only solution that I have browsed.
I have coded several Windows Applications using .Net for the bank for the past years and one of the ussual task is to create the Login Form.
I have posted previously one of the solution I use in doing it (Use Membership API in winForms).
Browsing for new things to do I found this link on MSDN which I think is a better article to read Unify Windows Forms and ASP.NET Providers for Credentials Management
Hope to hear some comments or better solution from you guys.....
I was absent yesterday because I was sick then I thought of formatting my Mobile Computer, after installing all the softwares I needed I figured out that I forgot one important thing. I forgot to save my bookmarks which always saves me minutes of browsing, when ever I stumble upon a problem which I forgot the solution..... So what i did was to look for some utility to at least allow me not to repeat this Stupidity....
I Found this great Plugin for Firefox http://www.foxmarks.com/
I tested it just right now and Wow it really works.. plus there's alot of additional features like sharing and etc.....
I was asked by a friend of mine on how to create a trigger that would trace the changes that a user did to a table. So i checked my bookmarks and give him this link
http://www.nigelrivett.net/SQLTriggers/Triggers_2_Creating_Audit_Trails.html
Hope to Get some of your opinions or maybe improvements on the topic inside the link above.
God Bless...
One of the task that a developer needs to accomplish is to code a module for logging, and creating it from scratch will take some of your precious time.
So to be a little more productive, we can use a tested library like Log4Net.
I have browsed for some pages and found a lot of variations. So putting it all together, here is the routine that i used to do...
Note:
the configuration file for Log4Net is found on another Config File, not on the App.Config
1. Download Log4net
http://logging.apache.org/log4net/
2. Extract the downloaded file in your preferred destination
3. Add a Reference to Log4Net.Dll (found inside "bin\net\2.0\release")
4. Create a new Config File named Log4Net.Config and paste the code below
<?xml version="1.0" ?>
<log4net>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
<file value="c:\log\" />
<appendToFile value="true" />
<datePattern value=".yyyyMMdd." />
<rollingStyle value="Date" />
<param name="StaticLogFileName" value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %exception %username %-5level %logger [%property{NDC}] - %message - %identity% newline" />
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="FileAppender"/>
</root>
</log4net>
for more information about the Log4Net Configuration you can visit
http://logging.apache.org/log4net/release/manual/configuration.html
------------------------------------------------------------------------------
5. Open AssemblyInfo.Cs and Add the bolded line below just after the last [assembly line
[assembly: AssemblyTitle("Log4NetExer1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Log4NetExer1")]
[assembly: AssemblyCopyright("Copyright © 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
6. place the following code in the load event of your main Form
private void Form1_Load(object sender, EventArgs e)
{
string log4netconfigfile = Application.StartupPath + @"\log4net.config";
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(log4netconfigfile));
}
7. And thats it you are ready to log log and log
sample logging
private void button1_Click(object sender, EventArgs e)
{
Logger.Info("Succesfullll");
Logger.Error("asdasdasd",new DivideByZeroException());
}
Hello IT friends hehehe Help naman po, Post naman a comment or critique about my Shots... Just want to know if there's improvement. Here's my Blog
Http://HumpreyCogay.BlogSpot.Com
Thank you....
More Posts
Next page »