الأربعاء، 7 نوفمبر 2012

Edit Data in a Read Only Grid (MSFlexGrid)


Basically, a textbox is positioned over the cell that you want to edit. When you click the cell, hit the Enter key or begin typing in the selected cell, its contents are copied into the textbox allowing you to make the desired changes. When the textbox looses focus the changed data is copied back to the grid cell and the textbox is hidden. The trick is to make this look and feel as transparent as possible. The key to doing this is positioning the textbox to correctly match the cell in the grid and allowing a simple means of navigating through the grid.

The arrow keys allow you to navigate through the cells in the grid. When you click a cell or press the Enter or Tab key, the textbox is displayed so that you can make your changes.
LogMeIn Free 14 Day PRO Trial - No credit card required.Once in this "Edit" mode, the horizontal arrow keys can be used to move through the textbox's data.
Pressing the vertical arrow, Enter or Tab key transfers the data back to the grid and takes you out of "Edit" mode. I check to make sure that clicking on a fixed row or column in the grid does not display the textbox. Also, I make sure the grid and textbox use the same size and style of font so that the textbox aligns correctly by setting these properties manually in the form's load event. You can add additional code to the textbox to validate and format the data before writing it back to the grid and to align it left or right so that it looks the same in the textbox as it does in the grid.


here is the code :



Option Explicit

Dim bDoNotEdit   As Boolean
Dim bOnFixedPart As Boolean

Private Sub Form_Click()
Call pSetCellValue
End Sub

Private Sub gridTest_Click()
'
' Display the textbox if the user clicked
' on a non-fixed row or column.
'
If bOnFixedPart Then Exit Sub
Call pEditGrid(32)
End Sub
Private Sub pEditGrid(KeyAscii As Integer)
'
' Populate the textbox and position it.
'
With txtEdit
    Select Case KeyAscii
        Case 0 To 32
            '
            ' Edit the current text.
            '
            .Text = gridTest
            .SelStart = 0
            .SelLength = 1000
            
        Case 8, 46, 48 To 57
            '
            ' Replace the current text but only
            ' if the user entered a number.
            '
            .Text = Chr(KeyAscii)
            .SelStart = 1
        Case Else
            '
            ' If an alpha character was entered,
            ' use a zero instead.
            '
            .Text = "0"
    End Select
End With
'
' Show the textbox at the right place.
'
With gridTest
    If .CellWidth < 0 Then Exit Sub
    txtEdit.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight
    '
    ' NOTE:
    '   Depending on the style of the Grid Lines that you set, you
    '   may need to adjust the textbox position slightly. For example
    '   if you use raised grid lines use the following:
    '
    'txtEdit.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth - 8, .CellHeight - 8
End With

txtEdit.Visible = True
txtEdit.SetFocus
End Sub
Private Sub gridTest_GotFocus()

If bDoNotEdit Then Exit Sub
'
' Copy the textbox's value to the grid
' and hide the textbox.
'
Call pSetCellValue
End Sub
Private Sub gridTest_KeyPress(KeyAscii As Integer)
'
' Display the textbox.
'
Call pEditGrid(KeyAscii)
End Sub
Private Sub gridTest_LeaveCell()

If bDoNotEdit Then Exit Sub
Call gridTest_GotFocus
End Sub
Private Sub gridTest_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim l      As Long
Dim lWidth As Long

With gridTest
    For l = 0 To .Cols - 1
        If .ColIsVisible(l) Then
            lWidth = lWidth + .ColWidth(l)
        End If
    Next
    '
    ' See if we are on the fixed part of the grid.
    '
    bOnFixedPart = (x < .ColWidth(0)) Or _
                   (x > lWidth) Or _
                   (y < .RowHeight(0)) Or _
                   (y > .Rows * .RowHeightMin)
End With
End Sub
Private Sub gridTest_Scroll()
Call gridTest_GotFocus
End Sub
Private Sub Form_Load()
Dim i As Long
'
' Set the grid and textbox
' to the same font.
'
With txtEdit.Font
    .Name = gridTest.Font.Name
    .Size = gridTest.Font.Size
    .Weight = gridTest.Font.Weight
End With
txtEdit.BackColor = vb3DLight
'
' Add some rows and columns to the grid so we
' have something to start with.
'
With gridTest
    .RowHeightMin = txtEdit.Height

    ' Size the first fixed column.
    .ColWidth(0) = .ColWidth(0) / 2
    .ColAlignment(0) = 1   ' Center center.
    
    ' Label the rows.
    For i = .FixedRows To .Rows - 1
         .TextArray(fLabel(i, 0)) = i
    Next
    
    ' Label the columns.
    For i = .FixedCols To .Cols - 1
        .TextArray(fLabel(0, i)) = i
    Next
    
    ' Right align data.
    For i = .FixedCols To .Cols - 1
        .ColAlignment(i) = flexAlignRightCenter
    Next
End With

txtEdit = ""
bDoNotEdit = False
End Sub
Private Function fLabel(lRow As Long, lCol As Long) As Long
    fLabel = lCol + gridTest.Cols * lRow
End Function
Private Sub txtEdit_KeyDown(KeyCode As Integer, Shift As Integer)
'
' See what key was pressed in the textbox.
'
With gridTest
    Select Case KeyCode
        Case 13   'ENTER
            .SetFocus
        Case 27   'ESC
             txtEdit.Visible = False
            .SetFocus
        Case 38   'Up arrow
            .SetFocus
            DoEvents
            If .Row > .FixedRows Then
                bDoNotEdit = True
                .Row = .Row - 1
                bDoNotEdit = False
            End If
        Case 40   'Down arrow
            .SetFocus
            DoEvents
            If .Row < .Rows - 1 Then
                bDoNotEdit = True
                .Row = .Row + 1
                bDoNotEdit = False
            End If
    End Select
End With
End Sub
Private Sub txtEdit_KeyPress(KeyAscii As Integer)
'
' Delete carriage returns to get rid of beep
' and only allow numbers.
'
Select Case KeyAscii
    Case Asc(vbCr)
        KeyAscii = 0
    Case 8, 46
    Case 48 To 57
    Case Else
        KeyAscii = 0
End Select
End Sub
Private Sub pSetCellValue()
'
' NOTE:
'       This code should be called anytime
'       the grid loses focus and the grid's
'       contents may change.  Otherwise, the
'       cell's new value may be lost and the
'       textbox may not line up correctly.
'
If txtEdit.Visible Then
    gridTest.Text = txtEdit.Text
    txtEdit.Visible = False
End If
End Sub




AVG Internet Security 2013

الثلاثاء، 6 نوفمبر 2012

Run ASP.NET Web Application from Command Prompt


Visual Studio has its own integrated ASP.NET Runtime engine, which helps to run any ASP.NET web application with in Visual Studio.  While running application from Visual Studio, you must have seen a popup notification in System Tray (As shown in below image) , which is notification of ASP.NET Development Server.
This ASP.NET Development Server is nothing but a executable file (WebDev.WebServer) which used by Visual Studio to execute you web application when it’s running in the context of Visual Studio.  You can find the executable file at<\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0> . This folder contain two different executable
  • WebDev.WebServer20.EXE
  • WebDev.WebServer40.EXE
WebDev.WebServer20 is targeted to CLR 2.0, which means all the ASP.NET Application which are targeted till FW .NET 3.5 will be taking care by WebDev.WebServer20.EXE and WebDev.WebServer40.EXE for ASP.NET 4.0 based application.
Now, let’s see how we can use these executable to run an ASP.NET 4.0 Application with out using Visual Studio. 

Step 1 : Open the Command Prompt for “Program Files (x86)\Common Files\microsoft shared\DevServer\10.0”
Easiest way to go there, type Cmd in the address bar ( If you are using Win 7), this will directly open command prompt with exact path .

Step 2: [Optional] Type WebDev.WebServer40 and Press Enter, this will open a popup window with the details of required parameter


LogMeIn Pro - Free Download

Step 3 : If you are done with review, type below command in your command prompt
Note : Port number should be valid and not in used by any other process and path is location of your published web apps.
Step 4: Once done, press Enter, you will see a pop up notification in system tray

If you double click on that icon you will get below window of ASP.NET Development server,


which is exactly same notification window which we used to get when we run some ASP.NET Application from Visual Studio.
This indicates your application is running now.
Step 4: Open IE > Type http://localhost:<portnumber> , you are there !

Ten hacker tricks to exploit SQL Server systems



Whether it is through manual poking and prodding or the use of security testing tools, malicious attackers employ a variety of tricks to break into SQL Server systems, both inside and outside your firewall. It stands to reason then, if the hackers are doing it, you need to carry the same attacks to test the security strength of your systems. Here are 10 hacker tricks to gain access and violate systems running SQL Server.


1. Direct connections via the Internet
These connections can be used to attach to SQL Servers sitting naked without firewall protection for the entire world to see (and access).DShield's Port Report shows just how many systems are sitting out there waiting to be attacked. I don't understand the logic behind making a critical server like this directly accessible from the Internet, but I still find this flaw in my assessments, and we all remember the effect the SQL Slammer worm had on so many vulnerable SQL Server systems. Nevertheless, these direct attacks can lead to denial of service, buffer overflows and more.
2. Vulnerability scanning
Vulnerability scanning often reveals weaknesses in the underlying OS, the Web application or the database system itself. Anything from missing SQL Server patches to Internet Information Services (IIS) configuration weaknesses to SNMP exploits can be uncovered by attackers and lead to database server compromise. The bad guys may use open source, home-grown or commercial tools. Some are even savvy enough to carry out their hacks manually from a command prompt. In the interest of time (and minimal wheel spinning), I recommend using commercial vulnerability assessment tools like QualysGuard from Qualys Inc. (for general scanning), WebInspect from SPI Dynamics (for Web application scanning) and Next Generation Security Software Ltd.'s NGSSquirrel for SQL Server (for database-specific scanning). They're easy to use, offer the most comprehensive assessment and, in turn, provide the best results. Figure 1 shows some SQL injection vulnerabilities you may be able to uncover.

Figure 1: Common SQL injection vulnerabilities found using WebInspect.
3. Enumerating the SQL Server Resolution Service
Running on UDP port 1434, this allows you to find hidden database instances and probe deeper into the system. Chip Andrews' SQLPing v 2.5is a great tool to use to look for SQL Server system(s) and determine version numbers (somewhat). This works even if your SQL Server instances aren't listening on the default ports. Also, a buffer overflow can occur when an overly long request for SQL Servers is sent to the broadcast address for UDP port 1434.


4. Cracking SA passwords

Deciphering SA passwords is also used by attackers to get into SQL Server databases. Unfortunately, in many cases, no cracking is needed since no password has been assigned (Oh, logic, where art thou?!). Yet another use for the handy-dandy SQLPing tool mentioned earlier. The commercial products AppDetective from Application Security Inc. and NGSSQLCrack from NGS Software Ltd. also have this capability.





5. Direct-exploit attacks
Direct attacks using tools such as Metasploit, shown in Figure 2, and its commercial equivalents (CANVAS and CORE IMPACT) are used to exploit certain vulnerabilities found during normal vulnerability scanning. This is typically the silver-bullet hack for attackers penetrating a system and performing code injection or gaining unauthorized command-line access.

Figure 2: SQL Server vulnerability exploitable using Metasploit's MSFConsole.
6. SQL injection
SQL injection attacks are executed via front-end Web applications that don't properly validate user input. Malformed SQL queries, including SQL commands, can be inserted directly into Web URLs and return informative errors, commands being executed and more. These attacks can be carried out manually -- if you have a lot of time. Once I discover that a server has a potential SQL injection vulnerability, I prefer to perform the follow-through using an automated tool, such as SPI Dynamics' SQL Injector, shown in Figure 3.

Figure 3: SPI Dynamics' SQL Injector tool automates the SQL injection process.
7. Blind SQL injection
These attacks go about exploiting Web applications and back-end SQL Servers in the same basic fashion as standard SQL injection. The big difference is that the attacker doesn't receive feedback from the Web server in the form of returned error messages. Such an attack is even slower than standard SQL injection given the guesswork involved. You need a good tool for this situation, and that's where Absinthe, shown in Figure 4, comes in handy.

Figure 4: Absinthe tool takes the pain out of blind SQL injection testing.
8. Reverse engineering the system
The reverse engineering trick looks for software exploits, memory corruption weaknesses and so on. In Exploiting Software: How to Break Codeby Greg Hoglund and Gary McGraw, you'll find a discussion about reverse engineering ploys.
9. Google hacks
Google hacks use the extraordinary power of the Google search engine to ferret out SQL Server errors -- such as "Incorrect syntax near" -- leaking from publicly accessible systems. Several Google queries are available at Johnny Long's Google Hacking Database. (Look in the sections titled Error Messages and Files containing passwords.) Hackers use Google to find passwords, vulnerabilities in Web servers, underlying operating systems, publicly available procedures and more that they can use to further compromise a SQL Server system. Combining these queries with Web site names via Google's 'site:' operator often turns up juicy info you never imagined you could unearth.
10. Perusing Web site source code
Source code can also turn up information that may lead to a SQL Server break in. Specifically, developers may store SQL Server authentication information in ASP scripts to simplify the authentication process. A manual assessment or Google could uncover this information in a split second.

How to Hack Apple's Mac App Store to Install Any App for Free


Well, that didn't take long. One day after the release of the new App Store from Apple, an anonymous user has posted the (very simple) steps to copy the signatures used to sign apps download from the store for use in any other app (paid, or free) to allow you to run them on your Mac. With that said, you'll be done in 7 quick steps.

Step 1 Install the latest version of Snow Leopard (10.6.6)

If you haven't already done so, you'll need to update to get the new Mac App Store. It's a painless process.

Step 2 Download a Free App from the Mac App Store

Twitter is a good candidate. This will give you the signature files you'll need to use to allow you to run other .app files.

Step 3 Find the Signature Files

Go to your Applications folder in Finder, locate Twitter (or whatever free app you just downloaded), right-click, and click "Show Package Contents".

Step 4 Copy the Signature Files

These are the keys to the vault, so to speak. Navigate to the "Contents" folder and copy the following:
_CodeSignature
_MASReceipt
CodeResources

Step 5 Download the Paid App of your Choice

You will still need to find a way to download or acquire the Mac App Store .app files for the apps you would like to install (As I cannot condone stealing software, I won't be linking to the Angry Birds backup file you misplaced in this post, but if you truly did loose an app, chances are it's not terribly hard to find.

Step 6 Sign the Paid App Using the Files from the Free App

Right-click on the paid app file and click "Show Package Contents". Open up the "Contents" folder and delete _CodeSignature, _MASReceipt, and CodeResources. Now paste in the files you copied from the Twitter.app (or whatever free app you downloaded).

Step 7 You're Done!

You can now play that Angry Birds app (and any other .app file from the new Mac App Store) to your heart's content. Just repeat the steps above.


Warnings
Don't steal software. It's a crime. This guide is intended to help you restore backups of apps you've already paid for.

الاثنين، 5 نوفمبر 2012

How to set up an HP Cloud account


The HP cloud service is now available to the general public. Signing up to use their service is a similar process to creating an AWS (Amazon Web Services) account.

Another cloud provider

HP want to supply the entire cloud space. You can buy a ready-rolled data center in a shipping container, integrate HP software with the private cloud flagship VMware vCloud, and get support through social media. HP now offer cloud services, with IT Service Management at the SaaS layer, dev and test at the SaaS layer, and computing, storage and CDN at the IaaS layer. HP’s cloud IaaS offering opened up for beta testing in May. The compute service is similar to what you can get from the reigning champion AWS — there’s an API for programmers and an easy-to-use web-based control panel for normal people. You can run a small instance for free for a while, and there’s all the cloud stuff of self-service, massive scaling, and utility billing.

The technology

HP has bet its cloud future on the success of the OpenStack cloud system. The HP cloud contains open source building blocks from the OpenStack project. The HP guys added all the parts required to turn OpenStack into a money-making service.
The internal workings of the HP cloud aren’t exposed to the general public, so the core technology is irrelevant to customers.
How can you tell if the software hidden away in HP’s data centers is OpenStack, Cloudstack or Eucalyptus?


Will it last?

Longevity is more important to the average customer than the technology used. If you are tying an enterprise to a cloud provider for a few years, you want to do your homework. OpenStack is a young project, and HP are early adopters. If OpenStack doesn’t make it to maturity then a lot of companies will suffer, including HP. HP doesn’t needs a huge amount of revenue from its new service. If the money doesn’t roll in, the project will be canned.

Customers can happily sign up to HP cloud for the long haul. An OpenStack early demise is extremely unlikely — the OpenStack project is backed by the heavyweights of the IT world. The board of directors includes high flyers from Rackspace, Dell, and Cisco. The failure of the new HP Cloud service is also unlikely (let’s just forget about that HP TouchPad fiasco). This company is in the same weight class as IBM, Microsoft, and Google. It can spend huge amounts of time, money and resources learning how to play AWS at its own game.


Sign up for HP Cloud

And why not sign up and poke around the web control panel, to see if you like it? It takes 20 minutes, no cash, and no fancy technology. This step-by-step procedure gets you to the control panel. These steps don’t guide you through consuming the HPCloud services. Open a web browser. Go to the URL https://www.hpcloud.com/. The HPCloud home page appears, with a big GET STARTED NOW button. Any similarity to http://aws.amazon.com/ is pure coincidence.

LogMeIn Pro - Free Download