hacking contest

hacking exploits security forum
hacking
compliance articles
upgrade backup exec
information security consultant

Full Version: Srcsec
coder
add reply,

- kinda weak in my opinion - it just looks for a few calls / subs that can be potentially dangerous if not checked. It does not check for buffer exploitations and the like.

- I'm not saying it's a bad app, just nothing special. I could do this in the command line with some perl expressions just as easily.

- Maybe some one would be nice enough to find a nicer (more extensive) code analyzer.
atomix
wink.gif great program by a cool guy. SrcSec written by Bob of dtors.net will check your c coding for insecure programming. this is extremely useful because insecure coding can lead to potential exploitation and manipulation of programs.
atomix
win32 version. had to get rid of all the sleep()'s for it to compile.
wicked
Ive got some nice code here Coder will paste a sample below ain't got anything to do with the above post though.... see what you think... it's bin done in Delphi.


is apart of a program that I use often called Genius Posted Else Where in here.
monitors ports on computer very nice look and feel if you ask me.


Current_stats.pass

CODE

unit current_stats;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 fngnetstat, dxTL, dxCntner;

type
 TStat = (stTCP,stUDP,stIP,stICMP);
 TfrmStats = class(TForm)
   UdpStats1: TUdpStats;
   TCPStats1: TTCPStats;
   IpStats1: TIpStats;
   IcmpStats1: TIcmpStats;
   dxtlStats: TdxTreeList;
   dxtlcStatsProperty: TdxTreeListMaskColumn;
   dxtlcStatsValue: TdxTreeListMaskColumn;
   procedure FormShow(Sender: TObject);
   procedure dxtlStatsCustomDraw(Sender: TObject; ACanvas: TCanvas;
     ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn;
     const AText: String; AFont: TFont; var AColor: TColor; ASelected,
     AFocused: Boolean; var ADone: Boolean);
 private
   { Private declarations }
 public
   { Public declarations }
   procedure ShowStats(Stat : TStat);
 end;

var
 frmStats: TfrmStats;

implementation

{$R *.DFM}

procedure TfrmStats.ShowStats(Stat : TStat);
var
  StatList : TCounterList;
  i : Integer;
begin
    case Stat of
    stTCP : begin
                 StatList := TCPStats1;
                 Caption := 'TCP/IP Statistics';
            end;
    stUDP : begin
                 StatList := UDPStats1;
                 Caption := 'UDP/IP Statistics';
            end;
    stIP : begin
                StatList := IPStats1;
                Caption := 'IP Statistics';
           end;
    stICMP : begin
                  StatList := ICMPStats1;
                  Caption := 'ICMP Statistics';
             end;
    else Exit;
    end;
    for i := 0 to StatList.Count - 1 do
    begin
         with dxtlStats.Add do
         begin
              Strings[0] := StatList.Counters[i].Name;
              Strings[1] := IntToStr(StatList.Counters[i].Value);
         end;
    end;
    if dxtlStats.Count > 0 then
    begin
         with dxtlStats.Items[0] do
         begin
              Focused := True;
              MakeVisible;
         end;
    end;
    ShowModal;
    Release;
end;

procedure TfrmStats.FormShow(Sender: TObject);
begin
    SetForegroundWindow(Handle);
end;

procedure TfrmStats.dxtlStatsCustomDraw(Sender: TObject; ACanvas: TCanvas;
 ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxTreeListColumn;
 const AText: String; AFont: TFont; var AColor: TColor; ASelected,
 AFocused: Boolean; var ADone: Boolean);
begin
    if ANode.HasChildren then
       Exit;
    if ASelected then
    begin
         AColor := clHighlight;
    end else
    begin
         if ANode.Parent = nil then
         begin
              if (ANode.Index mod 2 = 0) then
              begin
                   AColor := clWindow;
                   AFont.Color := clWindowText;
              end else
              begin
                   AColor := clInfoBk;
                   AFont.Color := clInfoText;
              end;
         end else
         begin
              if ANode.Index mod 2 = 0 then
              begin
                   AColor := clWindow;
                   AFont.Color := clWindowText;
              end else
              begin
                   AColor := clInfoBk;
                   AFont.Color := clInfoText;
              end;
         end;
    end;
end;

end.


Current_Connections.pass

CODE

unit current_connections;

interface

uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
 dxBar, fngnetstat, ComCtrls, ImgList, StdCtrls, Clipbrd, IniFiles, main,
 ElImgLst, dxDBGrid, dxTL, dxCntner, Db, dxmdaset, dxBarExtItems, dxDBCtrl;

type
 TfrmCurrentConnections = class(TForm)
   StatusBar1: TStatusBar;
   Conns: TFnugryIpConnectionList;
   dxBarManager1: TdxBarManager;
   dxbsiFile: TdxBarSubItem;
   dxbbClose: TdxBarButton;
   dxbsiEdit: TdxBarSubItem;
   dxbsiView: TdxBarSubItem;
   dxbcFilter: TdxBarCombo;
   dxbsiStatistics: TdxBarSubItem;
   dxbbTCP: TdxBarButton;
   dxbbUDP: TdxBarButton;
   dxbbIP: TdxBarButton;
   dxbbICMP: TdxBarButton;
   PrintDialog1: TPrintDialog;
   dxbpmCopy: TdxBarPopupMenu;
   dxbbCopyLocalPort: TdxBarButton;
   dxbbCopyRemoteIP: TdxBarButton;
   dxbbCopyRemotePort: TdxBarButton;
   dxbpmEntry: TdxBarPopupMenu;
   ilToolbar: TElImageList;
   dxmdConnections: TdxMemData;
   dxmdConnectionsProtocol: TStringField;
   dxmdConnectionsLocalPort: TIntegerField;
   dxmdConnectionsRemoteIP: TStringField;
   dxmdConnectionsRemotePort: TIntegerField;
   dxmdConnectionsStatus: TStringField;
   dsConnections: TDataSource;
   dxdbgConnections: TdxDBGrid;
   dxdbgConnectionsRecId: TdxDBGridColumn;
   dxdbgConnectionsProtocol: TdxDBGridMaskColumn;
   dxdbgConnectionsLocalPort: TdxDBGridMaskColumn;
   dxdbgConnectionsRemoteIP: TdxDBGridMaskColumn;
   dxdbgConnectionsRemotePort: TdxDBGridMaskColumn;
   dxdbgConnectionsStatus: TdxDBGridMaskColumn;
   dxbbCustomize: TdxBarButton;
   dxbpmExport: TdxBarPopupMenu;
   dxbbExportAll: TdxBarButton;
   dxbbExportSelected: TdxBarButton;
   SaveDialog1: TSaveDialog;
   dxbbLookupIP: TdxBarButton;
   dxbbLookupLocalPort: TdxBarButton;
   dxbbLookupRemotePort: TdxBarButton;
   dxbsiOptions: TdxBarSubItem;
   dxblbExport: TdxBarLargeButton;
   dxblbPrint: TdxBarLargeButton;
   dxblbCopy: TdxBarLargeButton;
   dxblbClear: TdxBarLargeButton;
   dxblbRefresh: TdxBarLargeButton;
   dxbbShowCaptions: TdxBarButton;
   procedure dxbbTCPClick(Sender: TObject);
   procedure dxbbUDPClick(Sender: TObject);
   procedure dxbbIPClick(Sender: TObject);
   procedure dxbbICMPClick(Sender: TObject);
   procedure dxbcFilterChange(Sender: TObject);
   procedure dxbbCloseClick(Sender: TObject);
   procedure FormCreate(Sender: TObject);
   procedure FormShow(Sender: TObject);
   procedure FormClose(Sender: TObject; var Action: TCloseAction);
   procedure dxbbCopyLocalPortClick(Sender: TObject);
   procedure dxbbCopyRemoteIPClick(Sender: TObject);
   procedure dxbbCopyRemotePortClick(Sender: TObject);
   procedure dxbbCustomizeClick(Sender: TObject);
   procedure dxdbgConnectionsSelectedCountChange(Sender: TObject);
   procedure FormDestroy(Sender: TObject);
   procedure dxdbgConnectionsCustomDraw(Sender: TObject; ACanvas: TCanvas;
     ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn;
     const AText: String; AFont: TFont; var AColor: TColor; ASelected,
     AFocused: Boolean; var ADone: Boolean);
   procedure dxbbExportAllClick(Sender: TObject);
   procedure dxbbExportSelectedClick(Sender: TObject);
   procedure dxBarManager1BarAdd(Sender: TdxBarManager; ABar: TdxBar);
   procedure dxbbLookupIPClick(Sender: TObject);
   procedure dxbbLookupLocalPortClick(Sender: TObject);
   procedure dxbbLookupRemotePortClick(Sender: TObject);
   procedure dxblbCopyClick(Sender: TObject);
   procedure dxblbClearClick(Sender: TObject);
   procedure dxblbRefreshClick(Sender: TObject);
   procedure dxbbShowCaptionsClick(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
   procedure CreateParams(Var params: TCreateParams ); override;
 end;

var
 frmCurrentConnections: TfrmCurrentConnections;

implementation

uses
 current_stats, nslookup, portinfo;

{$R *.DFM}

procedure TfrmCurrentConnections.CreateParams(Var params: TCreateParams );
begin
    inherited;
    Params.WndParent := GetDesktopWindow;
    Params.ExStyle := Params.ExStyle and not WS_EX_TOOLWINDOW or WS_EX_APPWINDOW;
end;

procedure TfrmCurrentConnections.dxbbTCPClick(Sender: TObject);
begin
    with TfrmStats.Create(nil) do
         ShowStats(stTCP);
end;

procedure TfrmCurrentConnections.dxbbUDPClick(Sender: TObject);
begin
    with TfrmStats.Create(nil) do
         ShowStats(stUDP);
end;

procedure TfrmCurrentConnections.dxbbIPClick(Sender: TObject);
begin
    with TfrmStats.Create(nil) do
         ShowStats(stIP);
end;

procedure TfrmCurrentConnections.dxbbICMPClick(Sender: TObject);
begin
    with TfrmStats.Create(nil) do
         ShowStats(stICMP);
end;

procedure TfrmCurrentConnections.dxbcFilterChange(Sender: TObject);
begin
    dxblbRefreshClick(nil);
end;

procedure TfrmCurrentConnections.dxbbCloseClick(Sender: TObject);
begin
    Close;
end;

procedure TfrmCurrentConnections.FormCreate(Sender: TObject);
begin
    if FOptions.FlatAppMenus then
    begin
         dxBarManager1.Style := bmsFlat;
         dxBarManager1.SunkenBorder := False;
    end else
    begin
         dxBarManager1.Style := bmsEnhanced;
         dxBarManager1.SunkenBorder := True;
    end;
    with TIniFile.Create(SameDir(INI_FILE)) do
    begin
         dxbcFilter.ItemIndex := ReadInteger('Current Connections','Filter',2);
         dxbbShowCaptions.Down := ReadBool('Current Connections','Show Button Captions',True);
         Free;
    end;
    dxbbShowCaptionsClick(nil);
    LoadStateFromReg(Self,'Current Connections');
end;

procedure TfrmCurrentConnections.FormShow(Sender: TObject);
begin
    SetForegroundWindow(Handle);
    if dxbcFilter.ItemIndex = 2 then
       dxblbRefreshClick(nil);
end;

procedure TfrmCurrentConnections.FormClose(Sender: TObject;
 var Action: TCloseAction);
begin
    Action := caFree;
end;

procedure TfrmCurrentConnections.dxbbCopyLocalPortClick(Sender: TObject);
begin
    if dxdbgConnections.SelectedCount > 0 then
       Clipboard.AsText := dxmdConnections.FieldByName('LocalPort').AsString;
end;

procedure TfrmCurrentConnections.dxbbCopyRemoteIPClick(Sender: TObject);
begin
    if dxdbgConnections.SelectedCount > 0 then
       Clipboard.AsText := dxmdConnections.FieldByName('RemoteIP').AsString;
end;

procedure TfrmCurrentConnections.dxbbCopyRemotePortClick(Sender: TObject);
begin
    if dxdbgConnections.SelectedCount > 0 then
       Clipboard.AsText := dxmdConnections.FieldByName('RemotePort').AsString;
end;

procedure TfrmCurrentConnections.dxbbCustomizeClick(Sender: TObject);
begin
    dxdbgConnections.ColumnsCustomizing;
end;

procedure TfrmCurrentConnections.dxdbgConnectionsSelectedCountChange(
 Sender: TObject);
begin
    dxblbCopy.Enabled := dxdbgConnections.SelectedCount > 0;
    dxbbExportSelected.Enabled := dxdbgConnections.SelectedCount > 0;
    dxbbLookupIP.Enabled := dxdbgConnections.SelectedCount > 0;
    dxbbLookupLocalPort.Enabled := dxdbgConnections.SelectedCount > 0;
    dxbbLookupRemotePort.Enabled := dxdbgConnections.SelectedCount > 0;
end;

procedure TfrmCurrentConnections.FormDestroy(Sender: TObject);
begin
    with TIniFile.Create(SameDir(INI_FILE)) do
    begin
         WriteInteger('Current Connections','Filter',dxbcFilter.ItemIndex);
         WriteBool('Current Connections','Show Button Captions',dxbbShowCaptions.Down);
         Free;
    end;
    SaveStateToReg(Self,'Current Connections');
end;

procedure TfrmCurrentConnections.dxdbgConnectionsCustomDraw(
 Sender: TObject; ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
 AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
 var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
var
  G : TdxDBGrid;
begin
    if ANode.HasChildren then
       Exit;
    G := Sender as TdxDBGrid;
    if ASelected then
    begin
         AColor := clHighlight;
    end else
    begin
         if ANode.Parent = nil then
         begin
              if ((egoLoadAllRecords in G.Options) and (ANode.Index mod 2 = 0)) or
                 (not (egoLoadAllRecords in G.Options)) and (G.DataSource.DataSet.RecNo mod 2 = 0) then
              begin
                   AColor := clWindow;
                   AFont.Color := clWindowText;
              end else
              begin
                   AColor := clInfoBk;
                   AFont.Color := clInfoText;
              end;
         end else
         begin
              if ANode.Index mod 2 = 0 then
              begin
                   AColor := clWindow;
                   AFont.Color := clWindowText;
              end else
              begin
                   AColor := clInfoBk;
                   AFont.Color := clInfoText;
              end;
         end;
    end;
end;

procedure TfrmCurrentConnections.dxbbExportAllClick(Sender: TObject);
begin
    if SaveDialog1.Execute then
    begin
         case SaveDialog1.FilterIndex of
         1 : dxdbgConnections.SaveToHTML(SaveDialog1.FileName,True);
         2 : dxdbgConnections.SaveAllToTextFile(SaveDialog1.FileName);
         3 : dxdbgConnections.SaveToXLS(SaveDialog1.FileName,True);
         end;
    end;
end;

procedure TfrmCurrentConnections.dxbbExportSelectedClick(Sender: TObject);
begin
    if SaveDialog1.Execute then
    begin
         case SaveDialog1.FilterIndex of
         1 : dxdbgConnections.SaveToHTML(SaveDialog1.FileName,False);
         2 : dxdbgConnections.SaveSelectedToTextFile(SaveDialog1.FileName);
         3 : dxdbgConnections.SaveToXLS(SaveDialog1.FileName,False);
         end;
    end;
end;

procedure TfrmCurrentConnections.dxBarManager1BarAdd(Sender: TdxBarManager;
 ABar: TdxBar);
begin
    ABar.AllowQuickCustomizing := False;
end;

procedure TfrmCurrentConnections.dxbbLookupIPClick(Sender: TObject);
begin
    with TfrmNSLookup.Create(nil) do
    begin
         edLookup.Text := dxmdConnections.FieldByName('RemoteIP').AsString;
         Show;
         dxbbLookupClick(nil);
    end;
end;

procedure TfrmCurrentConnections.dxbbLookupLocalPortClick(Sender: TObject);
begin
    with TfrmPortInfo.Create(nil) do
    begin
         Show;
         LookupPort(dxmdConnections.FieldByName('LocalPort').AsInteger);
    end;
end;

procedure TfrmCurrentConnections.dxbbLookupRemotePortClick(
 Sender: TObject);
begin
    with TfrmPortInfo.Create(nil) do
    begin
         Show;
         LookupPort(dxmdConnections.FieldByName('RemotePort').AsInteger);
    end;
end;

procedure TfrmCurrentConnections.dxblbCopyClick(Sender: TObject);
begin
    dxdbgConnections.CopySelectedToClipboard;
end;

procedure TfrmCurrentConnections.dxblbClearClick(Sender: TObject);
begin
    dxmdConnections.Active := False;
    dxmdConnections.Active := True;
    dxdbgConnections.Invalidate;
end;

procedure TfrmCurrentConnections.dxblbRefreshClick(Sender: TObject);
var
  i : Integer;
begin
    Screen.Cursor := crAppStart;
    StatusBar1.SimpleText := 'Checking...';
    dxmdConnections.Active := False;
    dxmdConnections.Active := True;
    dsConnections.DataSet := nil;
    case dxbcFilter.ItemIndex of
    0 : Conns.Protocols := [tcp_ip];
    1 : Conns.Protocols := [udp_ip];
    2 : Conns.Protocols := [udp_ip,tcp_ip];
    end;
    Conns.Refresh;
    for i := 0 to Conns.ConnCount - 1 do
    begin
         with Conns.Connections[i] do
         begin
              dxmdConnections.AppendRecord([i, IpProtoName, LocalPort, RemoteIpString, RemotePort, StateString]);
              dxmdConnections.First;
         end;
    end;
    dsConnections.DataSet := dxmdConnections;
    dxdbgConnections.Refresh;
    if dxdbgConnections.Count > 0 then
    begin
         with dxdbgConnections.Items[0] do
         begin
              Focused := True;
              MakeVisible;
         end;
    end;
    StatusBar1.SimpleText := '';
    Screen.Cursor := crDefault;
end;

procedure TfrmCurrentConnections.dxbbShowCaptionsClick(Sender: TObject);
begin
    SetBigButtonText(Self, dxbbShowCaptions.Down);
end;

end.


Also need dfm files will Attach all of the above for any Delphi Compilers to Look at.

Enjoy!

Wkd.

ps: Will Remove Annoying Code 2morro.

pps: Will Leave Attachment with short Description.

Laterz.




This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.

 
Invision Power Board © 2001-2005 Invision Power Services, Inc.