]> Zhao Yanbai Git Server - acecode.git/commitdiff
...
authorAceVest <zhaoyanbai@126.com>
Sun, 4 Jun 2017 10:15:13 +0000 (18:15 +0800)
committerAceVest <zhaoyanbai@126.com>
Sun, 4 Jun 2017 10:15:13 +0000 (18:15 +0800)
learn/go/protobuf/client.go [new file with mode: 0644]
learn/go/protobuf/install.md [new file with mode: 0644]
learn/go/protobuf/sample.pb.go [new file with mode: 0644]
learn/go/protobuf/sample.proto [new file with mode: 0644]
learn/go/protobuf/server.go [new file with mode: 0644]
learn/markdown/exploit_exercises_nebula.md

diff --git a/learn/go/protobuf/client.go b/learn/go/protobuf/client.go
new file mode 100644 (file)
index 0000000..81930d2
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * ------------------------------------------------------------------------
+ *   File Name: client.go
+ *      Author: Zhao Yanbai
+ *              2017-06-04 17:48:32 Sunday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+package main
+import (
+       "fmt"
+       "log"
+       "net"
+       "io"
+
+       "github.com/golang/protobuf/proto"
+)
+
+func main() {
+       defer fmt.Println("Program Exited...")
+
+       sampleData := sample.SampleData {
+               Title : "test golang protobuf",
+               Type : SAMPLE_TYPE_TEST,
+               Data : [1.414, 2.732, 3.14, 6.18],
+       }
+
+       data, err := proto.Marshal(sampleData)
+       if err != nil {
+               log.Fatal("marshaling error: ", err)
+       }
+
+       conn, err := net.Dial("tcp", ":8000")
+       if err != nil {
+               log.Fatal(err)
+       }
+
+       defer conn.Close()
+
+       if _, err := io.Copy(conn, data) {
+               log.Fatal(err)
+       }
+}
diff --git a/learn/go/protobuf/install.md b/learn/go/protobuf/install.md
new file mode 100644 (file)
index 0000000..dad1311
--- /dev/null
@@ -0,0 +1,5 @@
+1. 去`https://github.com/google/protobuf`下载代码
+2. 按`https://github.com/google/protobuf/tree/master/src`的方法编译安装
+3. `go get github.com/golang/protobuf` 
+4. 进入protobuf/protoc-gen-go `go build`
+5. `protoc --go_out=. sample.proto` 
diff --git a/learn/go/protobuf/sample.pb.go b/learn/go/protobuf/sample.pb.go
new file mode 100644 (file)
index 0000000..6d868f2
--- /dev/null
@@ -0,0 +1,128 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: sample.proto
+
+/*
+Package sample is a generated protocol buffer package.
+
+It is generated from these files:
+       sample.proto
+
+It has these top-level messages:
+       SampleData
+*/
+package sample
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
+
+type SampleType int32
+
+const (
+       SampleType_SAMPLE_TYPE_RAW         SampleType = 1
+       SampleType_SAMPLE_TYPE_LIGHT       SampleType = 2
+       SampleType_SAMPLE_TYPE_TEMPERATURE SampleType = 3
+       SampleType_SAMPLE_TYPE_HUMIDITY    SampleType = 4
+       SampleType_SAMPLE_TYPE_TEST        SampleType = 5
+)
+
+var SampleType_name = map[int32]string{
+       1: "SAMPLE_TYPE_RAW",
+       2: "SAMPLE_TYPE_LIGHT",
+       3: "SAMPLE_TYPE_TEMPERATURE",
+       4: "SAMPLE_TYPE_HUMIDITY",
+       5: "SAMPLE_TYPE_TEST",
+}
+var SampleType_value = map[string]int32{
+       "SAMPLE_TYPE_RAW":         1,
+       "SAMPLE_TYPE_LIGHT":       2,
+       "SAMPLE_TYPE_TEMPERATURE": 3,
+       "SAMPLE_TYPE_HUMIDITY":    4,
+       "SAMPLE_TYPE_TEST":        5,
+}
+
+func (x SampleType) Enum() *SampleType {
+       p := new(SampleType)
+       *p = x
+       return p
+}
+func (x SampleType) String() string {
+       return proto.EnumName(SampleType_name, int32(x))
+}
+func (x *SampleType) UnmarshalJSON(data []byte) error {
+       value, err := proto.UnmarshalJSONEnum(SampleType_value, data, "SampleType")
+       if err != nil {
+               return err
+       }
+       *x = SampleType(value)
+       return nil
+}
+func (SampleType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
+
+type SampleData struct {
+       Title            *string     `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"`
+       Type             *SampleType `protobuf:"varint,2,req,name=type,enum=sample.SampleType" json:"type,omitempty"`
+       Data             []string    `protobuf:"bytes,3,rep,name=data" json:"data,omitempty"`
+       XXX_unrecognized []byte      `json:"-"`
+}
+
+func (m *SampleData) Reset()                    { *m = SampleData{} }
+func (m *SampleData) String() string            { return proto.CompactTextString(m) }
+func (*SampleData) ProtoMessage()               {}
+func (*SampleData) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
+
+func (m *SampleData) GetTitle() string {
+       if m != nil && m.Title != nil {
+               return *m.Title
+       }
+       return ""
+}
+
+func (m *SampleData) GetType() SampleType {
+       if m != nil && m.Type != nil {
+               return *m.Type
+       }
+       return SampleType_SAMPLE_TYPE_RAW
+}
+
+func (m *SampleData) GetData() []string {
+       if m != nil {
+               return m.Data
+       }
+       return nil
+}
+
+func init() {
+       proto.RegisterType((*SampleData)(nil), "sample.SampleData")
+       proto.RegisterEnum("sample.SampleType", SampleType_name, SampleType_value)
+}
+
+func init() { proto.RegisterFile("sample.proto", fileDescriptor0) }
+
+var fileDescriptor0 = []byte{
+       // 201 bytes of a gzipped FileDescriptorProto
+       0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x4e, 0xcc, 0x2d,
+       0xc8, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x83, 0xf0, 0x94, 0xe2, 0xb8, 0xb8,
+       0x82, 0xc1, 0x2c, 0x97, 0xc4, 0x92, 0x44, 0x21, 0x11, 0x2e, 0xd6, 0x92, 0xcc, 0x92, 0x9c, 0x54,
+       0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x08, 0x47, 0x48, 0x8d, 0x8b, 0xa5, 0xa4, 0xb2, 0x20,
+       0x55, 0x82, 0x49, 0x81, 0x49, 0x83, 0xcf, 0x48, 0x48, 0x0f, 0x6a, 0x10, 0x44, 0x5f, 0x48, 0x65,
+       0x41, 0x6a, 0x10, 0x58, 0x5e, 0x48, 0x88, 0x8b, 0x25, 0x25, 0xb1, 0x24, 0x51, 0x82, 0x59, 0x81,
+       0x59, 0x83, 0x33, 0x08, 0xcc, 0xd6, 0x6a, 0x65, 0x84, 0x59, 0x00, 0x52, 0x28, 0x24, 0xcc, 0xc5,
+       0x1f, 0xec, 0xe8, 0x1b, 0xe0, 0xe3, 0x1a, 0x1f, 0x12, 0x19, 0xe0, 0x1a, 0x1f, 0xe4, 0x18, 0x2e,
+       0xc0, 0x28, 0x24, 0xca, 0x25, 0x88, 0x2c, 0xe8, 0xe3, 0xe9, 0xee, 0x11, 0x22, 0xc0, 0x24, 0x24,
+       0xcd, 0x25, 0x8e, 0x2c, 0x1c, 0xe2, 0xea, 0x1b, 0xe0, 0x1a, 0xe4, 0x18, 0x12, 0x1a, 0xe4, 0x2a,
+       0xc0, 0x2c, 0x24, 0xc1, 0x25, 0x82, 0x2c, 0xe9, 0x11, 0xea, 0xeb, 0xe9, 0xe2, 0x19, 0x12, 0x29,
+       0xc0, 0x22, 0x24, 0xc2, 0x25, 0x80, 0xaa, 0x2d, 0x38, 0x44, 0x80, 0x15, 0x10, 0x00, 0x00, 0xff,
+       0xff, 0x55, 0xab, 0x27, 0x80, 0xfe, 0x00, 0x00, 0x00,
+}
diff --git a/learn/go/protobuf/sample.proto b/learn/go/protobuf/sample.proto
new file mode 100644 (file)
index 0000000..308f92e
--- /dev/null
@@ -0,0 +1,17 @@
+package sample;
+
+enum SampleType {
+       SAMPLE_TYPE_RAW                 = 1;
+       SAMPLE_TYPE_LIGHT               = 2;
+       SAMPLE_TYPE_TEMPERATURE = 3;
+       SAMPLE_TYPE_HUMIDITY    = 4;
+       SAMPLE_TYPE_TEST                = 5;
+}
+
+message SampleData {
+       optional string title = 1;
+       required SampleType type = 2;
+       repeated string data = 3;
+};
+
+
diff --git a/learn/go/protobuf/server.go b/learn/go/protobuf/server.go
new file mode 100644 (file)
index 0000000..250e73b
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * ------------------------------------------------------------------------
+ *   File Name: server.go
+ *      Author: Zhao Yanbai
+ *              2017-06-04 17:48:30 Sunday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+package main
+import (
+       "fmt"
+       "sample"
+)
+
+func main() {
+       defer fmt.Println("Program Exited...")
+}
index 98c65f323d19128578ba0f0abffcb50d61f144bf..d9a2695abb82732a2f41eb091352ad8933ca4c08 100644 (file)
@@ -5,6 +5,11 @@ $ cat /etc/passwd | grep flag00
 flag00:x:999:999::/home/flag00:/bin/sh
 $ find / -uid 999 2>/dev/null
 ```
+Or
+
+```
+$ find / -user flag00 2>/dev/null
+```
 
 ##Level01