プロジェクト ファイルを追加します。
This commit is contained in:
parent
325fbb3905
commit
b96a06100d
25
Test.sln
Normal file
25
Test.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31112.23
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{A60DC222-7F65-4535-A71C-EF7EE6263E08}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A60DC222-7F65-4535-A71C-EF7EE6263E08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A60DC222-7F65-4535-A71C-EF7EE6263E08}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A60DC222-7F65-4535-A71C-EF7EE6263E08}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A60DC222-7F65-4535-A71C-EF7EE6263E08}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E3DD4713-8F53-44FB-9487-E544D1283CCE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
6
Test/App.config
Normal file
6
Test/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
104
Test/Program.cs
Normal file
104
Test/Program.cs
Normal file
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* DNS Test Tool
|
||||
*
|
||||
* Copyright (C) 2021 Kema All Rights Reserved.
|
||||
*
|
||||
*
|
||||
* How it work?
|
||||
* change content size and replace bytes.
|
||||
* last period to '02', else '04'
|
||||
* * I don't know the details either
|
||||
*
|
||||
* Reference
|
||||
* https://www.atmarkit.co.jp/ait/articles/1601/29/news014_2.html
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int fs = Environment.TickCount;
|
||||
byte[] header = new byte[12];
|
||||
header[0] = 00; // ID
|
||||
header[1] = 00;
|
||||
header[2] = 01; // Query
|
||||
header[3] = 00;
|
||||
header[4] = 00; // QDCount
|
||||
header[5] = 01;
|
||||
header[6] = 00; // ANCount
|
||||
header[7] = 00;
|
||||
header[8] = 00; // NSCount
|
||||
header[9] = 00;
|
||||
header[10] = 00; // ARCount
|
||||
header[11] = 00;
|
||||
|
||||
byte[] content = new byte[12];
|
||||
content[0] = 03; //offset
|
||||
content[1] = (byte)'w';
|
||||
content[2] = (byte)'w';
|
||||
content[3] = (byte)'w';
|
||||
content[4] = 02; //.
|
||||
content[5] = (byte)'j';
|
||||
content[6] = (byte)'p';
|
||||
content[7] = 00; //offset
|
||||
content[8] = 00; // A
|
||||
content[9] = 01;
|
||||
content[10] = 00; // IN
|
||||
content[11] = 01;
|
||||
|
||||
byte[] data = new byte[header.Length + content.Length];
|
||||
Array.Copy(header, 0, data, 0, header.Length);
|
||||
Array.Copy(content, 0, data, header.Length, content.Length);
|
||||
|
||||
IPAddress ip = IPAddress.Parse("8.8.8.8");
|
||||
IPEndPoint remote = new IPEndPoint(ip, 53);
|
||||
|
||||
UdpClient client = new UdpClient();
|
||||
|
||||
int et = Environment.TickCount;
|
||||
Console.WriteLine("Sending Packet.");
|
||||
client.Send(data, data.Length, remote);
|
||||
|
||||
IPEndPoint remoteIP = null;
|
||||
byte[] buffer = client.Receive(ref remoteIP);
|
||||
|
||||
int le = Environment.TickCount;
|
||||
|
||||
Console.WriteLine("Elapsed {0}ms", le - fs);
|
||||
Console.WriteLine("Elapsed creating data {0}ms", et - fs);
|
||||
Console.WriteLine(BitConverter.ToString(data));
|
||||
|
||||
byte[] answer = new byte[buffer.Length - data.Length];
|
||||
Array.Copy(buffer, data.Length, answer, 0, answer.Length);
|
||||
|
||||
Console.WriteLine(BitConverter.ToString(answer));
|
||||
|
||||
// offset
|
||||
//answer[0], answer[1]
|
||||
// A
|
||||
//answer[2], answer[3]
|
||||
// IN
|
||||
//answer[4], answer[5]
|
||||
|
||||
int offset = answer.Length - 4;
|
||||
int i0 = answer[offset + 0];
|
||||
int i1 = answer[offset + 1];
|
||||
int i2 = answer[offset + 2];
|
||||
int i3 = answer[offset + 3];
|
||||
|
||||
Console.WriteLine("{0}.{1}.{2}.{3}", i0, i1, i2, i3);
|
||||
|
||||
Console.ReadLine();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
36
Test/Properties/AssemblyInfo.cs
Normal file
36
Test/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。
|
||||
// 制御されます。アセンブリに関連付けられている情報を変更するには、
|
||||
// これらの属性値を変更します。
|
||||
[assembly: AssemblyTitle("Test")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Test")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから
|
||||
// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、
|
||||
// その型の ComVisible 属性を true に設定します。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
|
||||
[assembly: Guid("a60dc222-7f65-4535-a71c-ef7ee6263e08")]
|
||||
|
||||
// アセンブリのバージョン情報は次の 4 つの値で構成されています:
|
||||
//
|
||||
// メジャー バージョン
|
||||
// マイナー バージョン
|
||||
// ビルド番号
|
||||
// リビジョン
|
||||
//
|
||||
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
|
||||
// 既定値にすることができます:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
53
Test/Test.csproj
Normal file
53
Test/Test.csproj
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A60DC222-7F65-4535-A71C-EF7EE6263E08}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Test</RootNamespace>
|
||||
<AssemblyName>Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user