Quantcast
Channel: Silk Performer
Viewing all articles
Browse latest Browse all 4084

Wiki Page: How can I customize binary data in my script ?

$
0
0


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

Update on working with Binary data

Note that since SilkPerformer 6.0 it is now possible to concatenate a string in binary data using the bin function.
If we use the code sample above then we can now demonstrate how much more flexible working with binary data is in SilkPerformer 6.0

dcltranstransaction

  TmyTrans1 

var

sBin : 

string

; sNewvalue : 

string

;  

begin// original data // WebUrlPostBin("http://myServer.com/", // "\h14FFFFFFFF100000000B41434D452043" // 7777777777ACME C 00000000 // "\h6F6F726432120000002E636F6D2E696E" // oord27777.com.in 00000010 // "\h666F67726170682E6A6D79726961642E" // fograph.jmyriad. 00000020 // "\h7365727665722E4A4D534C6F61645061" // server.JMSLoadPa 00000030 // "\h67654D6574686F641300000018676574" // geMethod77777get 00000040 // "\h436163686564446973706C61794C6973" // CachedDisplayLis 00000050 // "\h74506174680800000012582424323433" // tPath77777X$$243 00000060 // "\h3437332476312D557365723108000000" // 473$v1-User17777 00000070 // "\h01310C0C0C0C", 134 ); // 717777 00000080

sNewvalue := 

"User2"

; 

//string we want to add to binary//SetMem function is no longer required

sBin :=  

"\h14FFFFFFFF100000000B41434D452043"// 7777777777ACME C 00000000"\h6F6F726432120000002E636F6D2E696E"// oord27777.com.in 00000010"\h666F67726170682E6A6D79726961642E"// fograph.jmyriad. 00000020"\h7365727665722E4A4D534C6F61645061"// server.JMSLoadPa 00000030"\h67654D6574686F641300000018676574"// geMethod77777get 00000040"\h436163686564446973706C61794C6973"// CachedDisplayLis 00000050"\h74506174680800000012582424323433"// tPath77777X$$243 00000060"\h3437332476312D"

+

bin

(sNewValue)+

"\h08000000"// 473$v1-User27777 00000070"\h01310C0C0C0C";// use bin function to concatenate the string directly into binary

WriteData(sBin, 

134

  ,OPT_WRITEDATA_HEX); 

//writes out sBin which contains modified binary// post sBin to the server //WebUrlPostBin("http://myServer.com",sBin,134,"application/java-serialized-object", 0.02);end

  TmyTrans1;  

----------------------------------
Please Note Since SilkPerformer 6.0 it is possible to concatenate a string in binary data using the bin function. See the section "Update on working with Binary data" below. To download the latest version of SilkPerformer click here Latest Version of SilkPerformer

This code demonstrates how you can randomize binary strings. Copy this code into a new SilkPerformer script and modify it by adding your own binary strings etc.

// Replaces string in binary data with new value
benchmark BenchmarkName

use"kernel.bdh"
use"WebApi.bdh"

dcluser
user
VirtUser
transactions
TmyTrans1 : 1;

// Transactions Section
dcltrans
transaction TmyTrans1
var
sBin : string;
sNewvalue : string;

begin
sNewvalue := "User2"; //string we want to add to binary
// original data
// WebUrlPostBin("http://myServer.com/",
// "\h14FFFFFFFF100000000B41434D452043" // 7777777777ACME C 00000000
// "\h6F6F726432120000002E636F6D2E696E" // oord27777.com.in 00000010
// "\h666F67726170682E6A6D79726961642E" // fograph.jmyriad. 00000020
// "\h7365727665722E4A4D534C6F61645061" // server.JMSLoadPa 00000030
// "\h67654D6574686F641300000018676574" // geMethod77777get 00000040
// "\h436163686564446973706C61794C6973" // CachedDisplayLis 00000050
// "\h74506174680800000012582424323433" // tPath77777X$$243 00000060
// "\h3437332476312D557365723108000000" // 473$v1-User17777 00000070
// "\h01310C0C0C0C", 134 ); // 717777 00000080

//In order to replace the User1 string with a new user name (sNewValue), we use the SetMem function as shown below.

//copies the original binary string into variable sBin for manipulation
SetMem(sBin, 1 ,
"\h14FFFFFFFF100000000B41434D452043"// 7777777777ACME C 00000000
"\h6F6F726432120000002E636F6D2E696E"// oord27777.com.in 00000010
"\h666F67726170682E6A6D79726961642E"// fograph.jmyriad. 00000020
"\h7365727665722E4A4D534C6F61645061"// server.JMSLoadPa 00000030
"\h67654D6574686F641300000018676574"// geMethod77777get 00000040
"\h436163686564446973706C61794C6973"// CachedDisplayLis 00000050
"\h74506174680800000012582424323433"// tPath77777X$$243 00000060
"\h3437332476312D557365723108000000"// 473$v1-User17777 00000070
"\h01310C0C0C0C", 134 );

WriteData(sBin, 134,OPT_WRITEDATA_HEX); //writes out original string
//use SetMem to change data starting at position 120 with new value of 5 chars
SetMem(sBin, 120, sNewValue, 5);
WriteData(sBin,134,OPT_WRITEDATA_HEX); //writes out sBin which contains modified binary
// post sBin to the server
//WebUrlPostBin("http://myServer.com",sBin,134,"application/java-serialized-object", 0.02);
end TmyTrans1;


Old KB# 19555

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>