小编Max*_*Max的帖子

在格式字符串漏洞攻击中访问数组的第二个元素

我正在开发一个格式字符串漏洞实验室,我们给出了以下代码:

#define SECRET1 0x44
#define SECRET2 0x55

int main(int argc, char *argv[])
{
  char user_input[100];
  int *secret;
  int int_input;
  int a, b, c, d; /* other variables, not used here.*/

  /* The secret value is stored on the heap */
  secret = (int *) malloc(2*sizeof(int));

  /* getting the secret */
  secret[0] = SECRET1; 
  secret[1] = SECRET2;

  printf("The variable secret's address is 0x%.8x (on stack)\n", &secret);
  printf("The variable secret's value is 0x%.8x (on heap)\n", secret);
  printf("secret[0]'s address is 0x%.8x (on heap)\n", …
Run Code Online (Sandbox Code Playgroud)

c security string exploit format-string

9
推荐指数
1
解决办法
2256
查看次数

从Azure CosmosDb加载F#脚本时缺少DLL异常

我正在尝试在针对我的Azure CosmosDb的F#脚本文件中测试一些不同的查询,但是当我尝试执行查询本身时,我收到有关丢失的DLL的错误.

我正在加载Documents.Client.dll:

#r "../packages/Microsoft.Azure.DocumentDB/lib/net45/Microsoft.Azure.Documents.Client.dll"
open Microsoft.Azure.Documents
open Microsoft.Azure.Documents.Client
open Microsoft.Azure.Documents.Linq
Run Code Online (Sandbox Code Playgroud)

但是当我执行一个查询时:

Seq.toList <| query {
            //some query that I copy & pasted from a working file
        }
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

System.AggregateException: One or more errors occurred. ---> System.DllNotFoundException: Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Microsoft.Azure.Documents.ServiceInteropWrapper.CreateServiceProvider(String configJsonString, IntPtr& serviceProvider)
   at Microsoft.Azure.Documents.Query.QueryPartitionProvider.Initialize()
   at Microsoft.Azure.Documents.Query.QueryPartitionProvider.GetPartitionedQueryExecutionInfoInternal(SqlQuerySpec querySpec, PartitionKeyDefinition partitionKeyDefinition, Boolean requireFormattableOrderByQuery, Boolean isContinuationExpected)
   at Microsoft.Azure.Documents.Query.DocumentQueryExecutionContextBase.<GetPartitionedQueryExecutionInfoAsync>d__0.MoveNext()
Run Code Online (Sandbox Code Playgroud)

(堆栈跟踪中有更多 - 这只是它的顶部).

我无法在ServiceInterop任何地方找到dll - …

f# azure

7
推荐指数
1
解决办法
292
查看次数

在Suave中允许使用CORS的多个标头

我正在尝试让我的Suave API接受CORS请求.我在这里关注了这个片段:

http://www.fssnip.net/mL/title/CORS-response-with-Suave

我将在这里重新创建:

let setCORSHeaders =
    setHeader  "Access-Control-Allow-Origin" "*"
    >=> setHeader "Access-Control-Allow-Headers" "content-type"

let allow_cors : WebPart =
    choose [
        OPTIONS >=>
            fun context ->
                context |> (
                    setCORSHeaders
                    >=> OK "CORS approved" )
    ]

let webSite =
    choose [
        allow_cors
        GET >=> OK "URLs are for wimps. GETting something? This is what you get."
    ]
Run Code Online (Sandbox Code Playgroud)

但是现在我的端点需要传入令牌,并且由于CORS中缺少允许的头,这些端点会出错.我的令牌标题只是"令牌",所以我尝试了两件事,但都没有解决问题.

尝试#1

    setHeader  "Access-Control-Allow-Origin" "*"
    >=> setHeader "Access-Control-Allow-Headers" "content-type"
    >=> setHeader "Access-Control-Allow-Headers" "token"
Run Code Online (Sandbox Code Playgroud)

这返回了一个错误,说content-type不再被接受 - 这似乎暗示最后一个setHeader覆盖了第一个,当你在这里查看源代码时:https://github.com/SuaveIO/suave/blob/master/src/Suave …

f# suave

6
推荐指数
1
解决办法
502
查看次数

在使用MVC托管时,无法通过AJAX调用WebAPI Controller

我有一个MVC应用程序,其中包含几个简单的页面,这些页面主要在Web API调用上运行.为简单起见,我想将它们包含在同一个项目中.我可以启动并导航到我的页面,但是当我尝试通过Ajax调用我的API时,我一直收到404错误 - 它无法找到API函数.

这是我的javascript文件:

$(document).ready(function () {
    //set the login button to call our test API function
    document.getElementById("login_submit").addEventListener("click", GetUser);

});

function GetUser() {
    var response = $.ajax({        
        url: '/api/User',
        method: 'GET',
        contentType: 'application/json; charset=utf-8',
        success: function (data) {
            alert("Success!");
        },
        error: function (request, status, error) {
            alert(error);
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

这是我的控制器:

namespace MyProject.Controllers.API
{
    public class UserController : ApiController
    {
        // GET api/<controller>
        [HttpGet]        
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/<controller>/5 …
Run Code Online (Sandbox Code Playgroud)

c# ajax asp.net-mvc routing asp.net-web-api

5
推荐指数
1
解决办法
4343
查看次数

动态构建包含在哪里过滤器

背景

我需要能够构建一个.Include,将结果过滤到特定日期或之前创建的记录.我不会知道原始LINQ语句中对象的类型,我将找到它们(通过大量的箍,但这是有效的).

我有一个像这样的对象图:

          A -> Ac
         /  \
  Bc <- B    \
       /      \  
Cc <- C        D -> Dc
Run Code Online (Sandbox Code Playgroud)

对象Ac,Bc,Cc,和Dc都是动态发现的(也就是写原来的LINQ语句时,开发者没有键入这些关系).然后需要将它们添加到IQueryable表达式,并仅返回特定DateTime的值.

迄今为止的守则

我尝试构建一个构造lambda并比较日期的函数.到目前为止,如果原始查询是A.Include(x => x.B).Include(x => x.B.Select(y => y.C),我可以构造字符串"A.B.Bc",所以我知道A,B和Bc的类型,以及它们的相关方式.

private static IQueryable<T> FilterChangeTrackerToDate<T>(this IQueryable<T> query, string includeString, DateTime targetDateTime)
{
    var param = Expression.Parameter( typeof( T ), "x" );

    var prop = Expression.Property(param, includeString + ".CreatedUtc");

    var dateConst = Expression.Constant(targetDateTime);

    var compare = Expression.LessThanOrEqual(prop, dateConst);

    var lambda = …
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework

5
推荐指数
1
解决办法
1590
查看次数

Cannot create ZipArchive in F#

I am trying to instantiate a ZipArchive class in System.IO.Compression in an F# project:

open System.IO
open System.IO.Compression
open System.IO.Compression.FileSystem //this line errors, as expected

// Define your library scripting code here

let directoryPath = @"C:\Users\max\Downloads"

let dirInfo = new DirectoryInfo(directoryPath)

let zippedFiles = dirInfo.GetFiles() 
|> Array.filter (fun x -> x.Extension.Equals(".zip"))

let fileStream = new FileStream(((Array.head zippedFiles).FullName), System.IO.FileMode.Open)

//this line does not compile, because ZipArchive is not defined
let archive = new System.IO.Compression.ZipArchive(fileStream)
Run Code Online (Sandbox Code Playgroud)

I can create the same thing in …

compression zip f# unzip

5
推荐指数
1
解决办法
372
查看次数

用F#在RavenDb中保存记录以添加额外的ID列

保存新的F#记录时,我Id@在RavenDb文档中获得了一个额外的列,当我在代码中加载或查看该对象时会显示该列;它甚至可以通过我的F#API转换为JSON。

这是我的F#记录类型:

type Campaign = { mutable Id : string; name : string; description : string }
Run Code Online (Sandbox Code Playgroud)

我没有做任何令人兴奋的事情来保存它:

let save c : Campaign =
    use session = store.OpenSession()
    session.Store(c)
    session.SaveChanges()
    c
Run Code Online (Sandbox Code Playgroud)

保存记录的新实例将创建ID为的文档campaigns/289。这是RavenDb中文档的全部价值:

{
    "Id@": "campaigns/289",
    "name": "Recreating Id bug",
    "description": "Hello StackOverflow!"
}
Run Code Online (Sandbox Code Playgroud)

现在,当我在C#中使用相同的数据库(和文档)时,我没有获得额外的Id@价值。这是我在C#中保存记录时的样子:

{
    "Description": "Hello StackOverflow!",
    "Name": "Look this worked fine",
}
Run Code Online (Sandbox Code Playgroud)

(此外-“名称”与“名称”表示我的文档中有2个名称列。至少我理解该问题)。

所以我的问题是:在RavenDb中保存F#记录时,如何摆脱Id@正在创建的额外属性?

f# ravendb

1
推荐指数
1
解决办法
99
查看次数