古詩詞大全網 - 個性簽名 - 他們是如何檢測我的IP的呢?

他們是如何檢測我的IP的呢?

保存為.asp文件。加壹個IP數據庫就OK了

非常簡單

調用代碼

----------------------

<%

session.codepage="936"

'==================================

'文件名:qmipv2.0.asp

'描述:簽名顯IP來源 V2.0

'作者:/、Screen khhx@vip.qq.com

'更新日期:2008-10-26

'=================================

dim ReqIP,User_Agent

ReqIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")

If ReqIP = "" Or IsNull(ReqIP) Then ReqIP = Request.ServerVariables("REMOTE_ADDR")

User_Agent = Request.ServerVariables("HTTP_USER_AGENT")

Response.ContentType = "image/gif"'定義輸出類型

dim bb,MyJpeg

Dim LocalFile

LocalFile = Server.MapPath("IpImg.gif") '註意修改背景圖片的位置。

Dim Jpeg

Set Jpeg = Server.CreateObject("Persits.Jpeg")

If -2147221005=Err then

Response.write "沒有這個組件,請安裝!" '檢查是否安裝AspJpeg組件

Response.End()

End If

Jpeg.Open (LocalFile) '打開圖片

If err.number then

Response.write"打開圖片失敗,請檢查路徑!"

Response.End()

End if

Dim aa

aa=Jpeg.Binary '將原始數據賦給aa

'=========加文字水印=================

Jpeg.Canvas.Font.Color = &Hff0000 '水印文字顏色

Jpeg.Canvas.Font.Family = "宋體" '字體

Jpeg.Canvas.Font.Bold = False '是否加粗

Jpeg.Canvas.Font.Size = 12 '字體大小

Jpeg.Canvas.Font.ShadowColor = &Hffffff '陰影色彩

Jpeg.Canvas.Font.ShadowYOffset = 1

Jpeg.Canvas.Font.ShadowXOffset = 1

Jpeg.Canvas.Brush.Solid = False

Jpeg.Canvas.Font.Quality = 10 ' '輸出質量

Jpeg.Canvas.PrintText 20, 18, "資料搜索完畢:"

Jpeg.Canvas.PrintText 180, 18, "/、Screen"

Jpeg.Canvas.PrintText 20, 26, "--------------------------------------"

Jpeg.Canvas.PrintText 24, 36, "IP地址: " & ReqIP

Jpeg.Canvas.PrintText 24, 52, "IP定位: " & Look_Ip(ReqIP)

Jpeg.Canvas.PrintText 24, 68, "操作系統: " & ClientInfo(0)

Jpeg.Canvas.PrintText 24, 84, "瀏覽器: " & ClientInfo(1)

Jpeg.Canvas.PrintText 20, 100, "--------------------------------------"

Jpeg.Canvas.PrintText 20, 116, "歡迎使用/、Screen IP定位系統"

Jpeg.Canvas.PrintText 20, 132, "聲明: 不能保證IP定位的100%正確"

Jpeg.Canvas.PrintText 20, 148, " 有壹定的誤差。以上僅供測試"

bb=Jpeg.Binary '將文字水印處理後的值賦給bb,這時,文字水印沒有不透明度

'============調整文字透明度================

Set MyJpeg = Server.CreateObject("Persits.Jpeg")

MyJpeg.OpenBinary aa

dim Logo1,cc

Set Logo1 = Server.CreateObject("Persits.Jpeg")

Logo1.OpenBinary bb

MyJpeg.DrawImage 0,0, Logo1, 0.9 '0.9是透明度

cc=MyJpeg.Binary '將最終結果賦值給cc,這時也可以生成目標圖片了

Response.BinaryWrite cc '將二進輸出給瀏覽器

set aa=nothing

set bb=nothing

set cc=nothing

Jpeg.close : Set Jpeg = Nothing

MyJpeg.Close : Set MyJpeg = Nothing

Logo1.Close : Set Logo1 = Nothing

' ============================================

' 返回IP地址信息

' ============================================

Function Look_Ip(IP)

Dim Wry, IPType, QQWryVersion, IpCounter

' 設置類對象

Set Wry = New TQQWry

' 開始搜索,並返回搜索結果

' 您可以根據 QQWry(IP) 返回值來判斷該IP地址在數據庫中是否存在,如果不存在可以執行其他的壹些操作

' 比如您自建壹個數據庫作為追捕等,這裏我就不詳細說明了

IPType = Wry.QQWry(IP)

' Country:國家地區字段

' LocalStr:省市及其他信息字段

Look_Ip = Wry.Country & " " & Wry.LocalStr

End Function

' ============================================

' 返回操作系統及瀏覽器

' ============================================

Function ClientInfo(sType)

If sType = 0 Then

If InStr(User_Agent, "Windows 98") Then

ClientInfo = "Windows 98"

ElseIf InStr(User_Agent, "Win 9x 4.90") Then

ClientInfo = "Windows ME"

ElseIf InStr(User_Agent, "Windows NT 5.0") Then

ClientInfo = "Windows 2000"

ElseIf InStr(User_Agent, "Windows NT 5.1") Then

ClientInfo = "Windows XP"

ElseIf InStr(User_Agent, "Windows NT 5.2") Then

ClientInfo = "Windows 2003"

ElseIf InStr(User_Agent, "Windows NT") Then

ClientInfo = "Windows NT"

ElseIf InStr(User_Agent, "unix") Or InStr(User_Agent, "Linux") Or InStr(User_Agent, "SunOS") Or InStr(User_Agent, "BSD") Then

ClientInfo = "Unix & Linux"

Else

ClientInfo = "Other"

End If

ElseIf sType = 1 Then

If InStr(User_Agent, "MSIE 8") Then

ClientInfo = "Microsoft? Internet Explorer 8.0"

ElseIf InStr(User_Agent, "MSIE 7") Then

ClientInfo = "Microsoft? Internet Explorer 7.0"

ElseIf InStr(User_Agent, "MSIE 6") Then

ClientInfo = "Microsoft? Internet Explorer 6.0"

ElseIf InStr(User_Agent, "MSIE 5") Then

ClientInfo = "Microsoft? Internet Explorer 5.0"

ElseIf InStr(User_Agent, "MSIE 4") Then

ClientInfo = "Microsoft?> Internet Explorer 4.0"

ElseIf InStr(User_Agent, "Netscape") Then

ClientInfo = "Netscape?"

ElseIf InStr(User_Agent, "Opera") Then

ClientInfo = "Opera?"

Else

ClientInfo = "Other"

End If

End If

End Function

' ============================================

' ScreenIP物理定位搜索類

' ============================================

Class TQQWry

' ============================================

' 變量聲名

' ============================================

Dim Country, LocalStr, Buf, OffSet

Private StartIP, EndIP, CountryFlag

Public QQWryFile

Public FirstStartIP, LastStartIP, RecordCount

Private Stream, EndIPOff

' ============================================

' 類模塊初始化

' ============================================

Private Sub Class_Initialize

Country = ""

LocalStr = ""

StartIP = 0

EndIP = 0

CountryFlag = 0

FirstStartIP = 0

LastStartIP = 0

EndIPOff = 0

QQWryFile = Server.MapPath("QQWry.dat") 'QQ IP庫路徑,要轉換成物理路徑

End Sub

' ============================================

' IP地址轉換成整數

' ============================================

Function IPToInt(IP)

Dim IPArray, i

IPArray = Split(IP, ".", -1)

FOr i = 0 to 3

If Not IsNumeric(IPArray(i)) Then IPArray(i) = 0

If CInt(IPArray(i)) < 0 Then IPArray(i) = Abs(CInt(IPArray(i)))

If CInt(IPArray(i)) > 255 Then IPArray(i) = 255

Next

IPToInt = (CInt(IPArray(0))*256*256*256) + (CInt(IPArray(1))*256*256) + (CInt(IPArray(2))*256) + CInt(IPArray(3))

End Function

' ============================================

' 整數逆轉IP地址

' ============================================

Function IntToIP(IntValue)

p4 = IntValue - Fix(IntValue/256)*256

IntValue = (IntValue-p4)/256

p3 = IntValue - Fix(IntValue/256)*256

IntValue = (IntValue-p3)/256

p2 = IntValue - Fix(IntValue/256)*256

IntValue = (IntValue - p2)/256

p1 = IntValue

IntToIP = Cstr(p1) & "." & Cstr(p2) & "." & Cstr(p3) & "." & Cstr(p4)

End Function

' ============================================

' 獲取開始IP位置

' ============================================

Private Function GetStartIP(RecNo)

OffSet = FirstStartIP + RecNo * 7

Stream.Position = OffSet

Buf = Stream.Read(7)

EndIPOff = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256)

StartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)

GetStartIP = StartIP

End Function

' ============================================

' 獲取結束IP位置

' ============================================

Private Function GetEndIP()

Stream.Position = EndIPOff

Buf = Stream.Read(5)

EndIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)

CountryFlag = AscB(MidB(Buf, 5, 1))

GetEndIP = EndIP

End Function

' ============================================

' 獲取地域信息,包含國家和和省市

' ============================================

Private Sub GetCountry(IP)

If (CountryFlag = 1 Or CountryFlag = 2) Then

Country = GetFlagStr(EndIPOff + 4)

If CountryFlag = 1 Then

LocalStr = GetFlagStr(Stream.Position)

' 以下用來獲取數據庫版本信息

If IP >= IPToInt("255.255.255.0") And IP <= IPToInt("255.255.255.255") Then

LocalStr = GetFlagStr(EndIPOff + 21)

Country = GetFlagStr(EndIPOff + 12)

End If

Else

LocalStr = GetFlagStr(EndIPOff + 8)

End If

Else

Country = GetFlagStr(EndIPOff + 4)

LocalStr = GetFlagStr(Stream.Position)

End If

' 過濾數據庫中的無用信息

Country = Trim(Country)

LocalStr = Trim(LocalStr)

If InStr(Country, "CZ88.NET") Then Country = "LeoYung.COM"

If InStr(LocalStr, "CZ88.NET") Then LocalStr = "LeoYung.COM"

End Sub

' ============================================

' 獲取IP地址標識符

' ============================================

Private Function GetFlagStr(OffSet)

Dim Flag

Flag = 0

Do While (True)

Stream.Position = OffSet

Flag = AscB(Stream.Read(1))

If(Flag = 1 Or Flag = 2 ) Then

Buf = Stream.Read(3)

If (Flag = 2 ) Then

CountryFlag = 2

EndIPOff = OffSet - 4

End If

OffSet = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256)

Else

Exit Do

End If

Loop

If (OffSet < 12 ) Then

GetFlagStr = ""

Else

Stream.Position = OffSet

GetFlagStr = GetStr()

End If

End Function

' ============================================

' 獲取字串信息

' ============================================

Private Function GetStr()

Dim c

GetStr = ""

Do While (True)

c = AscB(Stream.Read(1))

If (c = 0) Then Exit Do

'如果是雙字節,就進行高字節在結合低字節合成壹個字符

If c > 127 Then

If Stream.EOS Then Exit Do

GetStr = GetStr & Chr(AscW(ChrB(AscB(Stream.Read(1))) & ChrB(C)))

Else

GetStr = GetStr & Chr(c)

End If

Loop

End Function

' ============================================

' 核心函數,執行IP搜索

' ============================================

Public Function QQWry(DotIP)

Dim IP, nRet

Dim RangB, RangE, RecNo

IP = IPToInt (DotIP)

Set Stream = CreateObject("ADodb.Stream")

Stream.Mode = 3

Stream.Type = 1

Stream.Open

Stream.LoadFromFile QQWryFile

Stream.Position = 0

Buf = Stream.Read(8)

FirstStartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)

LastStartIP = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256) + (AscB(MidB(Buf, 8, 1))*256*256*256)

RecordCount = Int((LastStartIP - FirstStartIP)/7)

' 在數據庫中找不到任何IP地址

If (RecordCount <= 1) Then

Country = "未知"

QQWry = 2

Exit Function

End If

RangB = 0

RangE = RecordCount

Do While (RangB < (RangE - 1))

RecNo = Int((RangB + RangE)/2)

Call GetStartIP (RecNo)

If (IP = StartIP) Then

RangB = RecNo

Exit Do

End If

If (IP > StartIP) Then

RangB = RecNo

Else

RangE = RecNo

End If

Loop

Call GetStartIP(RangB)

Call GetEndIP()

If (StartIP <= IP) And ( EndIP >= IP) Then

' 沒有找到

nRet = 0

Else

' 正常

nRet = 3

End If

Call GetCountry(IP)

QQWry = nRet

End Function

' ============================================

' 類終結

' ============================================

Private Sub Class_Terminate

On ErrOr Resume Next

Stream.Close

If Err Then Err.Clear

Set Stream = Nothing

End Sub

End Class

%>