A easy Format String Vuln Example.

Re: A easy Format String Vuln Example.

Post by KthProg on Thu Feb 28, 2013 9:23 pm
([msg=74306]see Re: A easy Format String Vuln Example.[/msg])

Lol alright
Code: Select all
]Attribute VB_Name = "ESEWOInfo"
Option Explicit
Sub NewESEWO(Optional updating As Boolean = False)
On Error GoTo errhand
If CheckFilled(updating) Then
'******************************************************************************************
Dim retVal As Byte
Dim Shift, dZone, employee, injDate, injDesc, injWhere, tAction, dateval, col, safetyData, _
area, zone, tname, injured, sendTo, subject, body, sMatrix As String
    dateval = CStr(Sheets("SEWO").Range("M7"))
Dim month1, montha, montharray As Variant
    month1 = VBA.Split(dateval, "/", 3)
    montharray = Array("_", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
    montha = montharray(CInt(month1(0)))
Dim sewoNum As LongPtr
    sewoNum = CLngPtr(Range("N4"))
    If VBA.InStr(1, ActiveWorkbook.Name, "SEWO", vbTextCompare) <> 0 Then
        ActiveWorkbook.SaveAs _
        fileName:="J:\WCM\1.Safety\Forms\ESEWOs\SEWO " & sewoNum
    End If
safetyData = "J:\WCM\1.Safety\Safety Data " & Year(Now) & "\WCM Safety Data.xlsm"
sMatrix = "J:\WCM\1.Safety\Safety Data " & Year(Now) & "\S-Matrix Plant Wide.xlsm"
    Shift = Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").ShiftComB.Text
    dZone = Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").DeptComB.Text & " " _
    & Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").ZoneComB.Text
    employee = Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").Cells(6, 3).Text
    injDate = Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").Cells(7, 13).Text
    injDesc = Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").Cells(9, 3).Text
    injWhere = Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").Cells(12, 3).Text
    tAction = Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").Cells(9, 14).Text
Dim row1, row2, row3, row4, row5, row6, row7 As Byte
Dim wo As Integer
Dim cb1, cb2 As Boolean
'******************************************************************************************
Application.ScreenUpdating = False
    With Sheets("SEWO")
        area = .DeptComB.Text
        zone = .ZoneComB.Text
        tname = .Cells(7, 7).Text
        injured = .Cells(6, 3).Text
    End With
    If Not updating Then
        sendTo = "******@******.com; *****@********.com; *******@******.com; *****@******.com" 'keith, al, marge
        subject = "SEWO From Department: " & area & " Zone: " & zone
        body = "A SEWO has been filled out by " & tname & " For " & injured
        retVal = WorkOrderSubs.newMail((sendTo), (subject), (body))
    End If
        If ActiveWorkbook.Sheets("5 Why").UnsafeConditionOpB Then
            wo = MsgBox("You selected 'Unsafe Condition' as your root cause classification, would you like to send a work order to Maintenance?", vbYesNo)
            If wo = 6 Then
                WorkOrder.show
            End If
        End If
    If Not updating Then
        ActiveWindow.DisplayWorkbookTabs = True
        Application.DisplayFormulaBar = True
        Application.DisplayScrollBars = True
        ActiveWindow.DisplayHeadings = True
        Sheets("SEWO").UpdateCBut.Enabled = True
        Sheets("SEWO").SubmitCBut.Enabled = False
        Sheets("SEWO").SaveIncCBut.Enabled = False
        With Sheets("SEWO")
            .SketchImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Sketches\" & sewoNum & ".gif")
            .EmpSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\EMP\" & sewoNum & ".gif")
            .TLeadSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\TL\" & sewoNum & ".gif")
            .SupSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\SUP\" & sewoNum & ".gif")
            .MgrDeptSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\MD\" & sewoNum & ".gif")
            .SafMgrSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\SM\" & sewoNum & ".gif")
            .PlantMgrSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\PM\" & sewoNum & ".gif")
        End With
        With Sheets("Statement")
            .InjuredSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\Statement\" & sewoNum & ".gif")
            .WitnessSigImg.Picture = _
            LoadPicture("J:\WCM\1.Safety\Forms\Signatures\Witness\" & sewoNum & ".gif")
        End With
    End If
With Sheets("5 Why")
    cb1 = .UnsafeActOpB.Value
    cb2 = .UnsafeConditionOpB.Value
End With
With Sheets("SEWO")
    row2 = .InjuryComB.ListIndex + 36
    Select Case .DeptComB
        Case "Other"
            Select Case .ZoneComB
                Case "Quality"
                    col = "C"
                Case "Shipping"
                    col = "D"
                Case "Maintenance"
                    col = "E"
            End Select
        Case "Molding"
            Select Case .ZoneComB
                Case "1"
                    col = "F"
                Case "2"
                    col = "G"
                Case "3"
                    col = "H"
            End Select
        Case "Paint"
            Select Case .ZoneComB
                Case "1"
                    col = "I"
            End Select
        Case "Vac Form"
            Select Case .ZoneComB
                Case "1"
                    col = "J"
                Case "2"
                    col = "K"
            End Select
        Case "Foam"
            Select Case .ZoneComB
                Case "1"
                    col = "L"
                Case "2"
                    col = "M"
                Case "3"
                    col = "N"
            End Select
        Case "IP Assembly"
            Select Case .ZoneComB
                Case "1"
                    col = "O"
                Case "2"
                    col = "P"
                Case "3"
                    col = "Q"
                Case "4"
                    col = "R"
                Case "5"
                    col = "S"
                Case "6"
                    col = "T"
            End Select
        Case "HT SEQ"
            Select Case .ZoneComB
                Case "1"
                    col = "U"
                Case "2"
                    col = "V"
                Case "3"
                    col = "W"
            End Select
    End Select
    Select Case .Range("I12")
        Case "Head/ Neck"
            row1 = 6
        Case "Eye"
            row1 = 7
        Case "Shoulder"
            row1 = 8
        Case "Upper Arm"
            row1 = 9
        Case "Elbow/ Forearm"
            row1 = 10
        Case "Hand/ Finger/ Wrt"
            row1 = 11
        Case "Lower Back"
            row1 = 12
        Case "Chest"
            row1 = 13
        Case "Leg/ Knee"
            row1 = 14
        Case "Foot/ Ankle"
            row1 = 15
        Case "Other"
            row1 = 16
    End Select
    If .CompKnowOpB Then 'Competence/ Knowledge
        row3 = 54
    End If
    If .AttBehavOpB Then 'Attitude/ behavior
        row3 = 55
    End If
    If .ManagementOpB Then 'Management
        row3 = 56
    End If
    If .PrecaAttOpB Then 'Precautions/ Attention
        row3 = 57
    End If
    If .PersonalCondOpB Then 'Personal Conditions
        row3 = 58
    End If
    If .ToolsEquipOpB Then 'Tools/ Equipment
        row7 = 59
    End If
    If .ProcSystemsOpB Then 'Procedures/ Systems
        row7 = 60
    End If
    If .FirstAidOpB Then 'First Aid
        row5 = 26
    End If
    If .RecordableOpB Then 'Recordable
        row5 = 25
    End If
    If .LostTimeOpB Then 'Lost Time
        row5 = 24
    End If
    If .NearMissOpB Then 'Near Miss
        row5 = 29
    End If
End With
With Sheets("5 Why")
    If .UnsafeActOpB Then 'Unsafe Act
        row4 = 31
    End If
    If .UnsafeConditionOpB Then 'Unsafe Condition
        row6 = 30
    End If
End With
    If Not updating Then
        Workbooks.Open sMatrix, 3
    End If
    With Workbooks("S-Matrix Plant Wide.xlsm").Sheets(montha)
        .Activate
        .Range(col & row1) = .Range(col & row1) + 1
        .Range(col & row2) = .Range(col & row2) + 1
        .Range(col & row3) = .Range(col & row3) + 1
    'If cb1 Then
    ' .Range(col & row4) = .Range(col & row4) + 1
    'End If
        .Range(col & row5) = .Range(col & row5) + 1
    'If cb2 Then
    ' .Range(col & row6) = .Range(col & row6) + 1
    'End If
        .Range(col & row7) = .Range(col & row7) + 1
    End With
Application.ScreenUpdating = True
Workbooks("SEWO " & sewoNum & ".xlsm").Activate
If Not updating Then
    If Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").NearMissOpB Then
        Workbooks.Open safetyData, 3
        With Workbooks("WCM Safety Data.xlsm").Sheets("Near Miss")
        .Activate
        .Rows("3:3").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        .Range("A3").Formula = "=ROW()-2"
        .Range("B3") = Shift
        .Range("C3") = employee
        .Range("D3") = dZone
        .Range("E3") = injDate
        .Range("F3") = injDesc
        .Range("G3") = injWhere
        .Range("H3").Formula = _
        "='J:\WCM\1.Safety\Forms\ESEWOs\[SEWO " & sewoNum & ".xlsm]SEWO'!$U$16"
        .Range("I3").Formula = _
        "='J:\WCM\1.Safety\Forms\ESEWOs\[SEWO " & sewoNum & ".xlsm]SEWO'!$T$4"
        End With
    End If
    If Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").LostTimeOpB Then
        Workbooks.Open safetyData, 3
        With Workbooks("WCM Safety Data.xlsm").Sheets("LTI")
            .Activate
            .Rows("3:3").Select
            Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
            .Range("A3").Formula = "=ROW()-2"
            .Range("B3") = Shift
            .Range("C3") = employee
            .Range("D3") = dZone
            .Range("E3") = injDate
            .Range("F3") = injDesc
            .Range("G3") = injWhere
            .Range("H3").Formula = _
            "='J:\WCM\1.Safety\Forms\ESEWOs\[SEWO " & sewoNum & ".xlsm]SEWO'!$U$16"
            .Range("I3").Formula = _
            "='J:\WCM\1.Safety\Forms\ESEWOs\[SEWO " & sewoNum & ".xlsm]SEWO'!$T$4"
        End With
    End If
    If Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").RecordableOpB Then
        Workbooks.Open safetyData, 3
        With Workbooks("WCM Safety Data.xlsm").Sheets("Recordables")
            .Activate
            Rows("3:3").Select
            Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
            .Range("A3").Formula = "=ROW()-2"
            .Range("B3") = Shift
            .Range("C3") = employee
            .Range("D3") = dZone
            .Range("E3") = injDate
            .Range("F3") = injDesc
            .Range("G3") = injWhere
            .Range("H3").Formula = _
            "='J:\WCM\1.Safety\Forms\ESEWOs\[SEWO " & sewoNum & ".xlsm]SEWO'!$U$16"
            .Range("I3").Formula = _
            "='J:\WCM\1.Safety\Forms\ESEWOs\[SEWO " & sewoNum & ".xlsm]SEWO'!$T$4"
        End With
    End If
    If Workbooks("SEWO " & sewoNum & ".xlsm").Sheets("SEWO").FirstAidOpB Then
        Workbooks.Open safetyData, 3
        With Workbooks("WCM Safety Data.xlsm").Sheets("First Aids")
            .Activate
            .Rows("3:3").Select
            Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
            .Range("A3").Formula = "=ROW()-1"
            .Range("B3") = employee
            .Range("C3") = injDate
            .Range("D3") = injDesc
            .Range("E3") = injWhere
            .Range("F3") = tAction
        End With
    End If
End If
MsgBox ("Your SEWO has been submitted" & Chr(13) & "Press SAVE ALL")
Application.Quit
End If
errhand:
If Err.Number = 53 Then
    Resume Next
End If
End Sub

Good luck lol
User avatar
KthProg
Poster
Poster
 
Posts: 219
Joined: Wed Jan 23, 2013 7:06 pm
Blog: View Blog (0)


Re: A easy Format String Vuln Example.

Post by 3vilp4wn on Fri Mar 01, 2013 7:43 pm
([msg=74315]see Re: A easy Format String Vuln Example.[/msg])

2 things:

1.) I meant the Programming thread in "Computers", not "Missions".
2.) When posting a link, remove the "sid=..." from the URL. It can let people log in as you if they visit the link right after you post it. :?

I'll try to break it!
Do not mistake understanding for realization, and do not mistake realization for liberation
Evil Ninja Hackers
???
٩(͡๏̯͡๏)۶

1A4EAMboaXpgvUSmtRbVRqbfJrbyuGhyoo
User avatar
3vilp4wn
Poster
Poster
 
Posts: 144
Joined: Sun Feb 10, 2013 2:05 am
Location: The darkness.
Blog: View Blog (0)


Re: A easy Format String Vuln Example.

Post by LoGiCaL__ on Sun Mar 03, 2013 1:51 pm
([msg=74341]see Re: A easy Format String Vuln Example.[/msg])

3vilp4wn wrote:
KthProg wrote:I wouldnt mind hearing what types of threats those could be.

Post in the "Programming" thread with an example of your code and I'll help you. I can't say without looking at your code.


^ This. No one is gonna steal your code and use it. Well I can't say that but if your using vb .net etc.. then chances are slim. Anways posting code will almost get you a quicker response instead of having to go back and for and describe it win words.
User avatar
LoGiCaL__
Addict
Addict
 
Posts: 1062
Joined: Sun May 30, 2010 12:33 pm
Blog: View Blog (0)


Re: A easy Format String Vuln Example.

Post by KthProg on Wed Mar 06, 2013 2:56 pm
([msg=74380]see Re: A easy Format String Vuln Example.[/msg])

Well without the spreadsheet its attached to its difficult to tell which variables are user input.
Here, anything that gets its data from a Range() or Cell() is user input.

Lemme know if you manage to do something interesting lol.
User avatar
KthProg
Poster
Poster
 
Posts: 219
Joined: Wed Jan 23, 2013 7:06 pm
Blog: View Blog (0)


Previous

Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests